Fixed Issue #1 & Added proxy support

This commit is contained in:
huanghongxun
2015-06-24 13:45:00 +08:00
parent 7bfe7c3432
commit e5621d1a58
30 changed files with 623 additions and 578 deletions

View File

@@ -89,13 +89,13 @@ task proguard(type: proguard.gradle.ProGuardTask, dependsOn: jar) {
launch4j {
launch4jCmd = 'D:\\Develop\\Java\\Launch4j\\launch4j.exe'
supportUrl = 'http://www.mcbbs.net/thread-142335-1-1.html'
jreMinVersion = '1.6.0'
jreMinVersion = '1.7.0'
mainClassName = mainClass
icon = new File(project.buildDir, '../icon.ico').absolutePath
version = mavenVersion + '.0'
downloadUrl = 'http://java.com/download'
copyright = "Copyright(c) 2013-2014 huangyuhui."
copyright = "Copyright(c) 2013-2015 huangyuhui."
jar = new File(project.buildDir, 'libs/' + mavenGroupId + '-' + mavenVersion + '.jar').absolutePath
outfile = mavenGroupId + '-' + mavenVersion + '.exe'

Binary file not shown.

Before

Width:  |  Height:  |  Size: 573 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 309 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 248 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 657 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

View File

@@ -1,41 +0,0 @@
<launch4jConfig>
<dontWrapJar>false</dontWrapJar>
<headerType>gui</headerType>
<jar>F:\Documents\NetBeansProjects\HMCL\HMCL\build\libs\HMCL-2.1.3.jar</jar>
<outfile>F:\Documents\NetBeansProjects\HMCL\HMCL\build\libs\HMCL-2.1.3-Launch4j.exe</outfile>
<errTitle></errTitle>
<cmdLine></cmdLine>
<chdir></chdir>
<priority>normal</priority>
<downloadUrl>http://java.com/download</downloadUrl>
<supportUrl></supportUrl>
<stayAlive>false</stayAlive>
<manifest></manifest>
<icon>F:\Documents\NetBeansProjects\HMCL\HMCL\icon.ico</icon>
<jre>
<path></path>
<bundledJre64Bit>false</bundledJre64Bit>
<minVersion>1.6.0</minVersion>
<maxVersion></maxVersion>
<jdkPreference>preferJre</jdkPreference>
</jre>
<versionInfo>
<fileVersion>2.1.3.0</fileVersion>
<txtFileVersion>2.1.3.0</txtFileVersion>
<fileDescription>Hello Minecraft! Launcher</fileDescription>
<copyright>Copyright(c) 2013~2014 huangyuhui</copyright>
<productVersion>2.1.3.0</productVersion>
<txtProductVersion>2.1.3.0</txtProductVersion>
<productName>Hello Minecraft! Launcher</productName>
<companyName></companyName>
<internalName>Hello Minecraft! Launcher</internalName>
<originalFilename>HMCL-2.1.3.exe</originalFilename>
</versionInfo>
<messages>
<startupErr>启动程序时出现错误</startupErr>
<bundledJreErr>未找到内置Java</bundledJreErr>
<jreVersionErr>此程序需要Java</jreVersionErr>
<launcherErr>未找到Java</launcherErr>
<instanceAlreadyExistsMsg>已存在一个程序实例</instanceAlreadyExistsMsg>
</messages>
</launch4jConfig>

6
HMCL/proguard.pro vendored
View File

@@ -1,6 +1,6 @@
-libraryjars D:\Develop\Java\jdk1.6.0_45\jre\lib\rt.jar
-libraryjars D:\Develop\Java\jdk1.6.0_45\jre\lib\jce.jar
-libraryjars D:\Develop\Java\jdk1.6.0_45\jre\lib\jsse.jar
-libraryjars <java.home>/lib/rt.jar
-libraryjars <java.home>/lib/jce.jar
-libraryjars <java.home>/lib/jsse.jar
-dontoptimize
-dontshrink

View File

@@ -22,9 +22,14 @@ import java.awt.datatransfer.StringSelection;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.ParseException;
import javax.swing.ImageIcon;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import org.jackhuang.hellominecraft.C;
import org.jackhuang.hellominecraft.utils.functions.DoneListener0;
import org.jackhuang.hellominecraft.HMCLog;
@@ -38,6 +43,7 @@ import org.jackhuang.hellominecraft.launcher.utils.settings.Settings;
import org.jackhuang.hellominecraft.launcher.views.MainFrame;
import org.jackhuang.hellominecraft.lookandfeel.HelloMinecraftLookAndFeel;
import org.jackhuang.hellominecraft.utils.MessageBox;
import org.jackhuang.hellominecraft.utils.StrUtils;
/**
*
@@ -90,12 +96,24 @@ public final class Main implements DoneListener0 {
try {
UIManager.setLookAndFeel(new HelloMinecraftLookAndFeel());
} catch (Throwable ex) {
} catch (ParseException | UnsupportedLookAndFeelException ex) {
HMCLog.warn("Failed to set look and feel...", ex);
}
Settings.UPDATE_CHECKER.start();
if (StrUtils.isNotBlank(Settings.s().getProxyHost()) && StrUtils.isNotBlank(Settings.s().getProxyPort())) {
System.setProperty("http.proxyHost", Settings.s().getProxyHost());
System.setProperty("http.proxyPort", Settings.s().getProxyPort());
if (StrUtils.isNotBlank(Settings.s().getProxyUserName()) && StrUtils.isNotBlank(Settings.s().getProxyPassword()))
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(Settings.s().getProxyUserName(), Settings.s().getProxyPassword().toCharArray());
}
});
}
MainFrame.showMainFrame(Settings.isFirstLoad());
}
}
@@ -111,7 +129,7 @@ public final class Main implements DoneListener0 {
MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
try {
java.awt.Desktop.getDesktop().browse(new URI(C.URL_PUBLISH));
} catch (Throwable e) {
} catch (URISyntaxException | IOException e) {
HMCLog.warn("Failed to browse uri: " + C.URL_PUBLISH, e);
Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();

View File

@@ -46,8 +46,7 @@ public class DefaultGameLauncher extends GameLauncher {
downloadLibrariesEvent.register((sender, t) -> {
final TaskWindow dw = TaskWindow.getInstance();
ParallelTask parallelTask = new ParallelTask();
for (DownloadLibraryJob o : t) {
final DownloadLibraryJob s = (DownloadLibraryJob) o;
for (DownloadLibraryJob s : t) {
parallelTask.addDependsTask(new FileDownloadTask(s.url, s.path).setTag(s.name));
}
dw.addTask(parallelTask);

View File

@@ -26,7 +26,6 @@ import org.jackhuang.hellominecraft.utils.tinystream.CollectionUtils;
import org.jackhuang.hellominecraft.utils.Event;
import org.jackhuang.hellominecraft.utils.JavaProcess;
import org.jackhuang.hellominecraft.utils.MessageBox;
import org.jackhuang.hellominecraft.utils.functions.Predicate;
import org.jackhuang.hellominecraft.utils.ProcessThread;
import org.jackhuang.hellominecraft.utils.StrUtils;
import org.jackhuang.hellominecraft.views.LogWindow;
@@ -37,57 +36,44 @@ import org.jackhuang.hellominecraft.views.LogWindow;
*/
public class LaunchFinisher implements Event<List<String>> {
private final HashSet<Thread> al = new HashSet<Thread>();
private final HashSet<Thread> al = new HashSet<>();
@Override
public boolean call(Object sender, List<String> str) {
final GameLauncher obj = (GameLauncher) sender;
obj.launchEvent.register(new Event<JavaProcess>() {
@Override
public boolean call(Object sender, JavaProcess p) {
if (obj.getProfile().getLauncherVisibility() == 0 && !LogWindow.instance.isVisible())
System.exit(0);
else if (obj.getProfile().getLauncherVisibility() == 2)
MainFrame.instance.closeMessage();
else {
if (LogWindow.instance.isVisible())
LogWindow.instance.setExit(TrueDoneListener.instance);
MainFrame.instance.dispose();
}
Event<JavaProcess> event = new Event<JavaProcess>() {
@Override
public boolean call(Object sender, JavaProcess t) {
processThreadStopped((ProcessThread) sender, obj, t, false);
return true;
}
};
ProcessThread a = new ProcessThread(p, true, true);
a.stopEvent.register(new Event<JavaProcess>() {
@Override
public boolean call(Object sender, JavaProcess p) {
if (p.getExitCode() != 0 && p.getStdErrLines().size() > 0 && StrUtils.containsOne(p.getStdErrLines(),
Arrays.asList("Could not create the Java Virtual Machine.",
"Error occurred during initialization of VM",
"A fatal exception has occurred. Program will exit.")))
MessageBox.Show(C.i18n("launch.cannot_create_jvm"));
processThreadStopped((ProcessThread) sender, obj, p, false);
return true;
}
});
a.start();
al.add(a);
a = new ProcessThread(p, false, true);
a.stopEvent.register(event);
a.start();
al.add(a);
a = new ProcessThread(p, false, false);
a.stopEvent.register(event);
a.start();
al.add(a);
return true;
obj.launchEvent.register((sender1, p) -> {
if (obj.getProfile().getLauncherVisibility() == 0 && !LogWindow.instance.isVisible())
System.exit(0);
else if (obj.getProfile().getLauncherVisibility() == 2)
MainFrame.instance.closeMessage();
else {
if (LogWindow.instance.isVisible())
LogWindow.instance.setExit(TrueDoneListener.instance);
MainFrame.instance.dispose();
}
Event<JavaProcess> event = (sender2, t) -> {
processThreadStopped((ProcessThread) sender2, obj, t, false);
return true;
};
ProcessThread a = new ProcessThread(p, true, true);
a.stopEvent.register((sender3, p1) -> {
if (p1.getExitCode() != 0 && p1.getStdErrLines().size() > 0 && StrUtils.containsOne(p1.getStdErrLines(), Arrays.asList("Could not create the Java Virtual Machine.",
"Error occurred during initialization of VM",
"A fatal exception has occurred. Program will exit."))) MessageBox.Show(C.i18n("launch.cannot_create_jvm"));
processThreadStopped((ProcessThread) sender3, obj, p1, false);
return true;
});
a.start();
al.add(a);
a = new ProcessThread(p, false, true);
a.stopEvent.register(event);
a.start();
al.add(a);
a = new ProcessThread(p, false, false);
a.stopEvent.register(event);
a.start();
al.add(a);
return true;
});
obj.launch(str);
return true;
@@ -95,14 +81,7 @@ public class LaunchFinisher implements Event<List<String>> {
void processThreadStopped(ProcessThread t, GameLauncher obj, JavaProcess p, boolean forceTermintate) {
al.remove(t);
al.removeAll(CollectionUtils.sortOut(al, new Predicate<Thread>() {
@Override
public boolean apply(Thread t) {
return !t.isAlive();
}
}));
al.removeAll(CollectionUtils.sortOut(al, t1 -> !t1.isAlive()));
if (al.isEmpty() || forceTermintate) {
for (Thread a : al) a.interrupt();
al.clear();

View File

@@ -35,7 +35,8 @@ public final class Config {
@SerializedName("username")
private String username;
@SerializedName("clientToken")
private String clientToken;
private final String clientToken;
private String proxyHost, proxyPort, proxyUserName, proxyPassword;
@SerializedName("enableShadow")
private boolean enableShadow;
@SerializedName("theme")
@@ -160,4 +161,40 @@ public final class Config {
if(downloadtype >= DownloadType.values().length || downloadtype < 0) return null;
return DownloadType.values()[downloadtype];
}
public String getProxyHost() {
return proxyHost == null ? "" : proxyHost;
}
public void setProxyHost(String proxyHost) {
this.proxyHost = proxyHost;
Settings.save();
}
public String getProxyPort() {
return proxyPort == null ? "" : proxyPort;
}
public void setProxyPort(String proxyPort) {
this.proxyPort = proxyPort;
Settings.save();
}
public String getProxyUserName() {
return proxyUserName == null ? "" : proxyUserName;
}
public void setProxyUserName(String proxyUserName) {
this.proxyUserName = proxyUserName;
Settings.save();
}
public String getProxyPassword() {
return proxyPassword == null ? "" : proxyPassword;
}
public void setProxyPassword(String proxyPassword) {
this.proxyPassword = proxyPassword;
Settings.save();
}
}

View File

@@ -16,12 +16,13 @@
*/
package org.jackhuang.hellominecraft.launcher.utils.settings;
import com.google.gson.JsonSyntaxException;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import java.util.Objects;
import org.jackhuang.hellominecraft.C;
import org.jackhuang.hellominecraft.utils.functions.DoneListener0;
import org.jackhuang.hellominecraft.HMCLog;
import org.jackhuang.hellominecraft.launcher.Main;
import org.jackhuang.hellominecraft.utils.tinystream.CollectionUtils;
@@ -40,7 +41,7 @@ public final class Settings {
public static final File settingsFile = new File(IOUtils.currentDir(), "hmcl.json");
private static boolean isFirstLoad;
private static Config settings;
private static final Config settings;
public static final UpdateChecker UPDATE_CHECKER;
public static Config s() {
@@ -52,50 +53,39 @@ public final class Settings {
}
static {
settings = initSettings();
isFirstLoad = StrUtils.isBlank(settings.getUsername());
if(!getVersions().containsKey("Default"))
getVersions().put("Default", new Profile());
UPDATE_CHECKER = new UpdateChecker(new VersionNumber(Main.firstVer, Main.secondVer, Main.thirdVer),
"hmcl", settings.isCheckUpdate(), () -> Main.invokeUpdate());
}
private static Config initSettings() {
Config c = new Config();
if (settingsFile.exists()) {
try {
String str = FileUtils.readFileToString(settingsFile);
if (str == null || str.trim().equals("")) {
init();
HMCLog.log("Settings file is empty, use the default settings.");
} else {
settings = C.gsonPrettyPrinting.fromJson(str, Config.class);
Config d = C.gsonPrettyPrinting.fromJson(str, Config.class);
if(d != null) c = d;
}
HMCLog.log("Initialized settings.");
} catch (Exception e) {
} catch (IOException | JsonSyntaxException e) {
HMCLog.warn("Something happened wrongly when load settings.", e);
if (MessageBox.Show(C.i18n("settings.failed_load"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) {
init();
} else {
if (MessageBox.Show(C.i18n("settings.failed_load"), MessageBox.YES_NO_OPTION) == MessageBox.NO_OPTION) {
HMCLog.err("Cancelled loading settings.");
System.exit(1);
}
}
} else {
HMCLog.log("No settings file here, may be first loading.");
isFirstLoad = true;
init();
}
if(settings == null) init();
isFirstLoad = StrUtils.isBlank(settings.getUsername());
if(!settings.getConfigurations().containsKey("Default")) {
settings.getConfigurations().put("Default", new Profile());
}
UPDATE_CHECKER = new UpdateChecker(new VersionNumber(Main.firstVer, Main.secondVer, Main.thirdVer), "hmcl", settings.isCheckUpdate(), new DoneListener0() {
@Override
public void onDone() {
Main.invokeUpdate();
}
});
}
public static void init() {
settings = new Config();
save();
return c;
}
public static void save() {
@@ -107,13 +97,7 @@ public final class Settings {
}
public static Profile getVersion(String name) {
if (settings == null) {
return null;
}
if (settings.getConfigurations() == null) {
return null;
}
return settings.getConfigurations().get(name);
return getVersions().get(name);
}
public static Map<String, Profile> getVersions() {
@@ -121,31 +105,22 @@ public final class Settings {
}
public static void setVersion(Profile ver) {
if (ver == null) {
return;
}
settings.getConfigurations().put(ver.getName(), ver);
Objects.requireNonNull(ver);
getVersions().put(ver.getName(), ver);
}
public static Collection<Profile> getProfiles() {
return CollectionUtils.sortOut(settings.getConfigurations().values(), (t) -> t != null && t.getName() != null);
return CollectionUtils.sortOut(getVersions().values(), (t) -> t != null && t.getName() != null);
}
public static Profile getOneProfile() {
if(settings.getConfigurations().size() == 0) {
settings.getConfigurations().put("Default", new Profile());
}
return settings.getConfigurations().firstEntry().getValue();
}
public static boolean trySetVersion(Profile ver) {
if (ver == null || ver.getName() == null) {
if (ver == null || ver.getName() == null || getVersions().containsKey(ver.getName()))
return false;
}
if (settings.getConfigurations().containsKey(ver.getName())) {
return false;
}
settings.getConfigurations().put(ver.getName(), ver);
getVersions().put(ver.getName(), ver);
return true;
}
@@ -154,7 +129,6 @@ public final class Settings {
}
public static void delVersion(String ver) {
if (settings == null) return;
settings.getConfigurations().remove(ver);
getVersions().remove(ver);
}
}

View File

@@ -19,22 +19,14 @@
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="chkEnableShadow" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="btnCheckUpdate" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel7" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel14" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="txtBackgroundPath" max="32767" attributes="0"/>
@@ -43,8 +35,34 @@
</Group>
<Component id="cboDownloadSource" alignment="1" max="32767" attributes="0"/>
<Component id="cboTheme" alignment="1" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtProxyHost" min="-2" pref="80" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtProxyPort" min="-2" pref="80" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel6" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtProxyUsername" min="-2" pref="80" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel8" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtProxyPassword" min="-2" pref="80" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<Component id="chkEnableShadow" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="btnCheckUpdate" 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>
@@ -70,11 +88,22 @@
<Component id="cboTheme" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="chkEnableShadow" min="-2" max="-2" attributes="0"/>
<Component id="btnCheckUpdate" alignment="0" min="-2" pref="26" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="txtProxyHost" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="txtProxyPort" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="txtProxyUsername" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
<Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="txtProxyPassword" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
<Component id="jLabel8" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="119" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="chkEnableShadow" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnCheckUpdate" min="-2" pref="26" max="-2" attributes="0"/>
<EmptySpace pref="71" max="32767" attributes="0"/>
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
@@ -174,5 +203,60 @@
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="cboThemeItemStateChanged"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="launcher.proxy" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="txtProxyHost">
<Events>
<EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="txtProxyHostFocusLost"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="proxy.host" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="txtProxyPort">
<Events>
<EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="txtProxyPortFocusLost"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel5">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="proxy.port" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel6">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="proxy.username" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="txtProxyUsername">
<Events>
<EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="txtProxyUsernameFocusLost"/>
</Events>
</Component>
<Component class="javax.swing.JTextField" name="txtProxyPassword">
<Events>
<EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="txtProxyPasswordFocusLost"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel8">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="proxy.password" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Form>

View File

@@ -39,6 +39,10 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
initComponents();
txtBackgroundPath.setText(Settings.s().getBgpath());
txtProxyHost.setText(Settings.s().getProxyHost());
txtProxyPort.setText(Settings.s().getProxyPort());
txtProxyUsername.setText(Settings.s().getProxyUserName());
txtProxyPassword.setText(Settings.s().getProxyPassword());
cboDownloadSource.setSelectedIndex(Settings.s().getDownloadType());
cboTheme.setSelectedIndex(Settings.s().getTheme());
chkEnableShadow.setSelected(Settings.s().isEnableShadow());
@@ -66,6 +70,15 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
chkEnableShadow = new javax.swing.JCheckBox();
jLabel1 = new javax.swing.JLabel();
cboTheme = new javax.swing.JComboBox();
jLabel2 = new javax.swing.JLabel();
txtProxyHost = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
txtProxyPort = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
txtProxyUsername = new javax.swing.JTextField();
txtProxyPassword = new javax.swing.JTextField();
jLabel8 = new javax.swing.JLabel();
cboDownloadSource.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Mojang", "BMCLAPI(By bangbang93)" }));
cboDownloadSource.addItemListener(new java.awt.event.ItemListener() {
@@ -119,6 +132,40 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
}
});
jLabel2.setText(bundle.getString("launcher.proxy")); // NOI18N
txtProxyHost.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent evt) {
txtProxyHostFocusLost(evt);
}
});
jLabel3.setText(bundle.getString("proxy.host")); // NOI18N
txtProxyPort.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent evt) {
txtProxyPortFocusLost(evt);
}
});
jLabel5.setText(bundle.getString("proxy.port")); // NOI18N
jLabel6.setText(bundle.getString("proxy.username")); // NOI18N
txtProxyUsername.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent evt) {
txtProxyUsernameFocusLost(evt);
}
});
txtProxyPassword.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent evt) {
txtProxyPasswordFocusLost(evt);
}
});
jLabel8.setText(bundle.getString("proxy.password")); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@@ -127,17 +174,11 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(chkEnableShadow)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnCheckUpdate))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel7)
.addComponent(jLabel1)
.addComponent(jLabel14))
.addComponent(jLabel14)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
@@ -145,7 +186,30 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnSelBackgroundPath))
.addComponent(cboDownloadSource, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(cboTheme, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
.addComponent(cboTheme, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtProxyHost, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtProxyPort, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtProxyUsername, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtProxyPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(chkEnableShadow)
.addComponent(btnCheckUpdate))
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
@@ -165,10 +229,21 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
.addComponent(jLabel1)
.addComponent(cboTheme, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(chkEnableShadow)
.addComponent(btnCheckUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 119, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtProxyHost, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(txtProxyPort, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5)
.addComponent(txtProxyUsername, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6)
.addComponent(txtProxyPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chkEnableShadow)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCheckUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 71, Short.MAX_VALUE)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
@@ -200,8 +275,7 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
}//GEN-LAST:event_btnSelBackgroundPathActionPerformed
private void txtBackgroundPathFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtBackgroundPathFocusLost
String path = txtBackgroundPath.getText();
Settings.s().setBgpath(path);
Settings.s().setBgpath(txtBackgroundPath.getText());
MainFrame.instance.loadBackground();
}//GEN-LAST:event_txtBackgroundPathFocusLost
@@ -219,6 +293,22 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
MainFrame.instance.reloadColor();
}//GEN-LAST:event_cboThemeItemStateChanged
private void txtProxyHostFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtProxyHostFocusLost
Settings.s().setProxyHost(txtProxyHost.getText());
}//GEN-LAST:event_txtProxyHostFocusLost
private void txtProxyPortFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtProxyPortFocusLost
Settings.s().setProxyPort(txtProxyPort.getText());
}//GEN-LAST:event_txtProxyPortFocusLost
private void txtProxyUsernameFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtProxyUsernameFocusLost
Settings.s().setProxyUserName(txtProxyUsername.getText());
}//GEN-LAST:event_txtProxyUsernameFocusLost
private void txtProxyPasswordFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtProxyPasswordFocusLost
Settings.s().setProxyPassword(txtProxyPassword.getText());
}//GEN-LAST:event_txtProxyPasswordFocusLost
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnCheckUpdate;
private javax.swing.JButton btnSelBackgroundPath;
@@ -227,8 +317,17 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
private javax.swing.JCheckBox chkEnableShadow;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JTextField txtBackgroundPath;
private javax.swing.JTextField txtProxyHost;
private javax.swing.JTextField txtProxyPassword;
private javax.swing.JTextField txtProxyPort;
private javax.swing.JTextField txtProxyUsername;
// End of variables declaration//GEN-END:variables
}