mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-01-30 14:39:56 +08:00
Fixed #45
This commit is contained in:
parent
019fcf314b
commit
587df1f5bb
@ -1,129 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.jackhuang.hellominecraft.util.C;
|
||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||
import org.jackhuang.hellominecraft.launcher.util.MinecraftCrashAdvicer;
|
||||
import org.jackhuang.hellominecraft.util.DoubleOutputStream;
|
||||
import org.jackhuang.hellominecraft.util.LauncherPrintStream;
|
||||
import org.jackhuang.hellominecraft.util.Utils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public final class Launcher {
|
||||
|
||||
static final Logger LOGGER = Logger.getLogger(Launcher.class.getName());
|
||||
|
||||
static String classPath = "";
|
||||
|
||||
public static void main(String[] args) {
|
||||
LOGGER.log(Level.INFO, "*** {0} ***", Main.makeTitle());
|
||||
|
||||
boolean showInfo = false;
|
||||
String mainClass = "net.minecraft.client.Minecraft";
|
||||
|
||||
ArrayList<String> cmdList = new ArrayList<>();
|
||||
|
||||
for (String s : args)
|
||||
if (s.startsWith("-cp="))
|
||||
classPath = classPath.concat(s.substring("-cp=".length()));
|
||||
else if (s.startsWith("-mainClass="))
|
||||
mainClass = s.substring("-mainClass=".length());
|
||||
else if (s.equals("-debug"))
|
||||
showInfo = true;
|
||||
else
|
||||
cmdList.add(s);
|
||||
|
||||
String[] tokenized = StrUtils.tokenize(classPath, File.pathSeparator);
|
||||
int len = tokenized.length;
|
||||
|
||||
if (showInfo) {
|
||||
try {
|
||||
File logFile = new File("hmclmc.log");
|
||||
if (!logFile.exists() && !logFile.createNewFile())
|
||||
LOGGER.info("Failed to create log file");
|
||||
else {
|
||||
FileOutputStream tc = new FileOutputStream(logFile);
|
||||
DoubleOutputStream out = new DoubleOutputStream(tc, System.out);
|
||||
System.setOut(new LauncherPrintStream(out));
|
||||
DoubleOutputStream err = new DoubleOutputStream(tc, System.err);
|
||||
System.setErr(new LauncherPrintStream(err));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LOGGER.log(Level.SEVERE, "Failed to add log file appender.", e);
|
||||
}
|
||||
|
||||
LOGGER.log(Level.INFO, "Arguments: '{'\n{0}\n'}'", StrUtils.parseParams(" ", args, "\n"));
|
||||
LOGGER.log(Level.INFO, "Main Class: {0}", mainClass);
|
||||
LOGGER.log(Level.INFO, "Class Path: '{'\n{0}\n'}'", StrUtils.parseParams(" ", tokenized, "\n"));
|
||||
}
|
||||
|
||||
URL[] urls = new URL[len];
|
||||
|
||||
try {
|
||||
for (int j = 0; j < len; j++)
|
||||
urls[j] = new File(tokenized[j]).toURI().toURL();
|
||||
} catch (Throwable e) {
|
||||
LOGGER.log(Level.SEVERE, "Failed to get classpath.", e);
|
||||
return;
|
||||
}
|
||||
|
||||
Method minecraftMain;
|
||||
URLClassLoader ucl = new URLClassLoader(urls, URLClassLoader.getSystemClassLoader().getParent());
|
||||
Thread.currentThread().setContextClassLoader(ucl);
|
||||
try {
|
||||
minecraftMain = ucl.loadClass(mainClass).getMethod("main", String[].class);
|
||||
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException t) {
|
||||
LOGGER.log(Level.SEVERE, "Minecraft main class not found.", t);
|
||||
return;
|
||||
}
|
||||
|
||||
LOGGER.info("*** Launching Game ***");
|
||||
|
||||
int flag = 0;
|
||||
try {
|
||||
minecraftMain.invoke(null, new Object[] { (String[]) cmdList.toArray(new String[cmdList.size()]) });
|
||||
} catch (Throwable throwable) {
|
||||
String trace = StrUtils.getStackTrace(throwable);
|
||||
System.err.println(C.i18n("crash.minecraft"));
|
||||
System.err.println(MinecraftCrashAdvicer.getAdvice(trace));
|
||||
System.err.println(trace);
|
||||
flag = 1;
|
||||
}
|
||||
|
||||
LOGGER.info("*** Game Exited ***");
|
||||
|
||||
try {
|
||||
Utils.shutdownForcely(flag);
|
||||
} catch (Exception e) {
|
||||
LOGGER.log(Level.SEVERE, "Failed to shut down this process...", e);
|
||||
}
|
||||
}
|
||||
}
|
@ -76,6 +76,8 @@ public class MojangDownloadProvider extends IDownloadProvider {
|
||||
public String getParsedLibraryDownloadURL(String str) {
|
||||
if (str == null)
|
||||
return null;
|
||||
else if (str.contains("scala-swing") || str.contains("scala-xml") || str.contains("scala-parser-combinators"))
|
||||
return str.replace("http://files.minecraftforge.net/maven", "http://ftb.cursecdn.com/FTB2/maven/");
|
||||
else if (str.contains("typesafe") || str.contains("scala"))
|
||||
if (SupportedLocales.NOW_LOCALE.self == Locale.CHINA)
|
||||
return str.replace("http://files.minecraftforge.net/maven", "http://maven.oschina.net/content/groups/public");
|
||||
|
@ -30,7 +30,6 @@ import org.jackhuang.hellominecraft.util.system.OS;
|
||||
import org.jackhuang.hellominecraft.util.system.Platform;
|
||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||
import org.jackhuang.hellominecraft.util.Utils;
|
||||
import org.jackhuang.hellominecraft.launcher.Launcher;
|
||||
import org.jackhuang.hellominecraft.launcher.core.GameException;
|
||||
import org.jackhuang.hellominecraft.launcher.core.auth.UserProfileProvider;
|
||||
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
|
||||
@ -130,12 +129,6 @@ public abstract class AbstractMinecraftLoader implements IMinecraftLoader {
|
||||
|
||||
if (OS.os() != OS.WINDOWS)
|
||||
res.add("-Duser.home=" + gameDir.getParent());
|
||||
|
||||
if (!options.isCanceledWrapper()) {
|
||||
res.add("-cp");
|
||||
res.add(StrUtils.parseParams("", Utils.getURLString(), File.pathSeparator));
|
||||
res.add(Launcher.class.getCanonicalName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -168,9 +161,6 @@ public abstract class AbstractMinecraftLoader implements IMinecraftLoader {
|
||||
if (options.isFullscreen())
|
||||
res.add("--fullscreen");
|
||||
|
||||
if (options.isDebug() && !options.isCanceledWrapper())
|
||||
res.add("-debug");
|
||||
|
||||
if (StrUtils.isNotBlank(options.getProxyHost()) && StrUtils.isNotBlank(options.getProxyPort()) && MathUtils.canParseInt(options.getProxyPort())) {
|
||||
res.add("--proxyHost");
|
||||
res.add(options.getProxyHost());
|
||||
|
@ -30,7 +30,7 @@ public class LaunchOptions {
|
||||
|
||||
private String name, versionName, javaArgs, minecraftArgs, maxMemory, permSize, width, height, serverIp, wrapper;
|
||||
private String proxyHost, proxyPort, proxyUser, proxyPass, javaDir, launchVersion, type, precalledCommand;
|
||||
private boolean fullscreen, debug, noJVMArgs, canceledWrapper;
|
||||
private boolean fullscreen, noJVMArgs;
|
||||
private JdkVersion java;
|
||||
private File gameDir;
|
||||
private GameDirType gameDirType;
|
||||
@ -127,14 +127,6 @@ public class LaunchOptions {
|
||||
this.fullscreen = fullscreen;
|
||||
}
|
||||
|
||||
public boolean isDebug() {
|
||||
return debug;
|
||||
}
|
||||
|
||||
public void setDebug(boolean debug) {
|
||||
this.debug = debug;
|
||||
}
|
||||
|
||||
public GameDirType getGameDirType() {
|
||||
return gameDirType;
|
||||
}
|
||||
@ -167,14 +159,6 @@ public class LaunchOptions {
|
||||
this.minecraftArgs = minecraftArgs;
|
||||
}
|
||||
|
||||
public boolean isCanceledWrapper() {
|
||||
return canceledWrapper;
|
||||
}
|
||||
|
||||
public void setCanceledWrapper(boolean canceledWrapper) {
|
||||
this.canceledWrapper = canceledWrapper;
|
||||
}
|
||||
|
||||
public String getServerIp() {
|
||||
return serverIp;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
|
||||
|
||||
@Override
|
||||
protected void makeSelf(List<String> res) throws GameException {
|
||||
StringBuilder library = new StringBuilder(options.isCanceledWrapper() ? "" : "-cp=");
|
||||
StringBuilder library = new StringBuilder("");
|
||||
for (MinecraftLibrary l : version.libraries)
|
||||
if (l.allow() && !l.isRequiredToUnzip())
|
||||
library.append(l.getFilePath(gameDir).getAbsolutePath()).append(File.pathSeparator);
|
||||
@ -51,11 +51,9 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
|
||||
if (!f.exists())
|
||||
throw new GameException("Minecraft jar does not exists");
|
||||
library.append(IOUtils.tryGetCanonicalFilePath(f)).append(File.pathSeparator);
|
||||
if (options.isCanceledWrapper())
|
||||
res.add("-cp");
|
||||
res.add("-cp");
|
||||
res.add(library.toString().substring(0, library.length() - File.pathSeparator.length()));
|
||||
String mainClass = version.mainClass;
|
||||
res.add((options.isCanceledWrapper() ? "" : "-mainClass=") + mainClass);
|
||||
res.add(version.mainClass);
|
||||
|
||||
String[] splitted = StrUtils.tokenize(version.minecraftArguments);
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class VersionSetting {
|
||||
|
||||
private String javaArgs, minecraftArgs, maxMemory, permSize, width, height;
|
||||
private String javaDir, precalledCommand, serverIp, java, wrapper;
|
||||
private boolean fullscreen, debug, noJVMArgs, canceledWrapper;
|
||||
private boolean fullscreen, noJVMArgs;
|
||||
|
||||
/**
|
||||
* 0 - Close the launcher when the game starts.<br/>
|
||||
@ -59,7 +59,7 @@ public class VersionSetting {
|
||||
public transient final EventHandler<String> propertyChanged = new EventHandler<>(this);
|
||||
|
||||
public VersionSetting() {
|
||||
debug = fullscreen = canceledWrapper = false;
|
||||
fullscreen = false;
|
||||
launcherVisibility = 1;
|
||||
gameDirType = 0;
|
||||
javaDir = java = minecraftArgs = serverIp = precalledCommand = wrapper = "";
|
||||
@ -76,11 +76,9 @@ public class VersionSetting {
|
||||
fullscreen = v.fullscreen;
|
||||
javaArgs = v.javaArgs;
|
||||
javaDir = v.javaDir;
|
||||
debug = v.debug;
|
||||
minecraftArgs = v.minecraftArgs;
|
||||
permSize = v.permSize;
|
||||
gameDirType = v.gameDirType;
|
||||
canceledWrapper = v.canceledWrapper;
|
||||
noJVMArgs = v.noJVMArgs;
|
||||
launcherVisibility = v.launcherVisibility;
|
||||
precalledCommand = v.precalledCommand;
|
||||
@ -193,15 +191,6 @@ public class VersionSetting {
|
||||
propertyChanged.execute("fullscreen");
|
||||
}
|
||||
|
||||
public boolean isDebug() {
|
||||
return debug;
|
||||
}
|
||||
|
||||
public void setDebug(boolean debug) {
|
||||
this.debug = debug;
|
||||
propertyChanged.execute("debug");
|
||||
}
|
||||
|
||||
public LauncherVisibility getLauncherVisibility() {
|
||||
return LauncherVisibility.values()[launcherVisibility];
|
||||
}
|
||||
@ -249,15 +238,6 @@ public class VersionSetting {
|
||||
propertyChanged.execute("minecraftArgs");
|
||||
}
|
||||
|
||||
public boolean isCanceledWrapper() {
|
||||
return canceledWrapper;
|
||||
}
|
||||
|
||||
public void setCanceledWrapper(boolean canceledWrapper) {
|
||||
this.canceledWrapper = canceledWrapper;
|
||||
propertyChanged.execute("canceledWrapper");
|
||||
}
|
||||
|
||||
public String getPrecalledCommand() {
|
||||
return precalledCommand;
|
||||
}
|
||||
@ -287,8 +267,6 @@ public class VersionSetting {
|
||||
|
||||
public LaunchOptions createLaunchOptions(File gameDir) {
|
||||
LaunchOptions x = new LaunchOptions();
|
||||
x.setCanceledWrapper(isCanceledWrapper());
|
||||
x.setDebug(isDebug());
|
||||
x.setFullscreen(isFullscreen());
|
||||
x.setWrapper(getWrapper());
|
||||
x.setGameDir(gameDir);
|
||||
|
@ -388,52 +388,45 @@
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="txtWrapperLauncher" alignment="0" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="lblPrecalledCommand1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="103" alignment="0" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="txtPrecalledCommand" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="txtServerIP" alignment="0" max="32767" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="lblPrecalledCommand" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="chkDebug" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="chkCancelWrapper" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="chkNoJVMArgs" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="lblServerIP" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="263" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="lblMinecraftArgs" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblPermSize" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblJavaArgs" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="txtJavaArgs" max="32767" attributes="0"/>
|
||||
<Component id="txtMinecraftArgs" max="32767" attributes="0"/>
|
||||
<Component id="txtPermSize" alignment="1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="txtWrapperLauncher" alignment="0" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="lblPrecalledCommand1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="txtPrecalledCommand" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="txtServerIP" alignment="0" max="32767" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="lblPrecalledCommand" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblServerIP" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="716" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="lblMinecraftArgs" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblPermSize" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblJavaArgs" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="txtJavaArgs" max="32767" attributes="0"/>
|
||||
<Component id="txtMinecraftArgs" max="32767" attributes="0"/>
|
||||
<Component id="txtPermSize" alignment="1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="chkNoJVMArgs" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
@ -467,27 +460,13 @@
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="txtServerIP" min="-2" pref="26" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="168" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="chkDebug" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="chkNoJVMArgs" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="chkCancelWrapper" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="chkNoJVMArgs" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JCheckBox" name="chkDebug">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="advancedsettings.debug_mode" replaceFormat="C.i18n("{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="chkDebugItemStateChanged"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="lblJavaArgs">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
@ -539,16 +518,6 @@
|
||||
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="chkNoJVMArgsItemStateChanged"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="chkCancelWrapper">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="advancedsettings.cancel_wrapper_launcher" replaceFormat="C.i18n("{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="chkCancelWrapperItemStateChanged"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="lblPrecalledCommand">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
|
@ -277,7 +277,6 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
btnChoosingGameDir = new javax.swing.JButton();
|
||||
btnCleanGame = new javax.swing.JButton();
|
||||
pnlAdvancedSettings = new AnimatedPanel();
|
||||
chkDebug = new javax.swing.JCheckBox();
|
||||
lblJavaArgs = new javax.swing.JLabel();
|
||||
txtJavaArgs = new javax.swing.JTextField();
|
||||
txtMinecraftArgs = new javax.swing.JTextField();
|
||||
@ -285,7 +284,6 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
lblPermSize = new javax.swing.JLabel();
|
||||
txtPermSize = new javax.swing.JTextField();
|
||||
chkNoJVMArgs = new javax.swing.JCheckBox();
|
||||
chkCancelWrapper = new javax.swing.JCheckBox();
|
||||
lblPrecalledCommand = new javax.swing.JLabel();
|
||||
txtPrecalledCommand = new javax.swing.JTextField();
|
||||
lblServerIP = new javax.swing.JLabel();
|
||||
@ -517,13 +515,6 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
|
||||
tabVersionEdit.addTab(C.i18n("settings"), pnlSettings); // NOI18N
|
||||
|
||||
chkDebug.setText(C.i18n("advancedsettings.debug_mode")); // NOI18N
|
||||
chkDebug.addItemListener(new java.awt.event.ItemListener() {
|
||||
public void itemStateChanged(java.awt.event.ItemEvent evt) {
|
||||
chkDebugItemStateChanged(evt);
|
||||
}
|
||||
});
|
||||
|
||||
lblJavaArgs.setText(C.i18n("advancedsettings.jvm_args")); // NOI18N
|
||||
|
||||
txtJavaArgs.setToolTipText(C.i18n("advancedsettings.java_args_default")); // NOI18N
|
||||
@ -556,13 +547,6 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
}
|
||||
});
|
||||
|
||||
chkCancelWrapper.setText(C.i18n("advancedsettings.cancel_wrapper_launcher")); // NOI18N
|
||||
chkCancelWrapper.addItemListener(new java.awt.event.ItemListener() {
|
||||
public void itemStateChanged(java.awt.event.ItemEvent evt) {
|
||||
chkCancelWrapperItemStateChanged(evt);
|
||||
}
|
||||
});
|
||||
|
||||
lblPrecalledCommand.setText(C.i18n("advancedsettings.precall_command")); // NOI18N
|
||||
|
||||
txtPrecalledCommand.addFocusListener(new java.awt.event.FocusAdapter() {
|
||||
@ -591,40 +575,35 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
pnlAdvancedSettings.setLayout(pnlAdvancedSettingsLayout);
|
||||
pnlAdvancedSettingsLayout.setHorizontalGroup(
|
||||
pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(pnlAdvancedSettingsLayout.createSequentialGroup()
|
||||
.addGap(0, 0, 0)
|
||||
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(pnlAdvancedSettingsLayout.createSequentialGroup()
|
||||
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(txtWrapperLauncher)
|
||||
.addGroup(pnlAdvancedSettingsLayout.createSequentialGroup()
|
||||
.addComponent(lblPrecalledCommand1)
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(pnlAdvancedSettingsLayout.createSequentialGroup()
|
||||
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(txtPrecalledCommand)
|
||||
.addComponent(txtServerIP)
|
||||
.addComponent(txtWrapperLauncher)
|
||||
.addGroup(pnlAdvancedSettingsLayout.createSequentialGroup()
|
||||
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(lblPrecalledCommand)
|
||||
.addGroup(pnlAdvancedSettingsLayout.createSequentialGroup()
|
||||
.addComponent(chkDebug)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(chkCancelWrapper)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(chkNoJVMArgs))
|
||||
.addComponent(lblServerIP))
|
||||
.addGap(0, 263, Short.MAX_VALUE))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlAdvancedSettingsLayout.createSequentialGroup()
|
||||
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(lblMinecraftArgs)
|
||||
.addComponent(lblPermSize)
|
||||
.addComponent(lblJavaArgs))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(txtJavaArgs)
|
||||
.addComponent(txtMinecraftArgs)
|
||||
.addComponent(txtPermSize, javax.swing.GroupLayout.Alignment.TRAILING))))))
|
||||
.addComponent(lblPrecalledCommand1)
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
.addComponent(txtPrecalledCommand)
|
||||
.addComponent(txtServerIP)
|
||||
.addGroup(pnlAdvancedSettingsLayout.createSequentialGroup()
|
||||
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(lblPrecalledCommand)
|
||||
.addComponent(lblServerIP))
|
||||
.addGap(0, 716, Short.MAX_VALUE))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlAdvancedSettingsLayout.createSequentialGroup()
|
||||
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(lblMinecraftArgs)
|
||||
.addComponent(lblPermSize)
|
||||
.addComponent(lblJavaArgs))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(txtJavaArgs)
|
||||
.addComponent(txtMinecraftArgs)
|
||||
.addComponent(txtPermSize, javax.swing.GroupLayout.Alignment.TRAILING))))
|
||||
.addGroup(pnlAdvancedSettingsLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(chkNoJVMArgs)
|
||||
.addGap(0, 0, Short.MAX_VALUE))
|
||||
);
|
||||
pnlAdvancedSettingsLayout.setVerticalGroup(
|
||||
pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
@ -654,10 +633,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
.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, 168, Short.MAX_VALUE)
|
||||
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(chkDebug)
|
||||
.addComponent(chkNoJVMArgs)
|
||||
.addComponent(chkCancelWrapper))
|
||||
.addComponent(chkNoJVMArgs)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
@ -1138,16 +1114,6 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setFullscreen(chkFullscreen.isSelected());
|
||||
}//GEN-LAST:event_chkFullscreenItemStateChanged
|
||||
|
||||
private void chkDebugItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkDebugItemStateChanged
|
||||
if (!isLoading)
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setDebug(chkDebug.isSelected());
|
||||
}//GEN-LAST:event_chkDebugItemStateChanged
|
||||
|
||||
private void chkCancelWrapperItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkCancelWrapperItemStateChanged
|
||||
if (!isLoading)
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setCanceledWrapper(chkCancelWrapper.isSelected());
|
||||
}//GEN-LAST:event_chkCancelWrapperItemStateChanged
|
||||
|
||||
private void chkNoJVMArgsItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkNoJVMArgsItemStateChanged
|
||||
if (!isLoading)
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setNoJVMArgs(chkNoJVMArgs.isSelected());
|
||||
@ -1207,10 +1173,8 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
txtMinecraftArgs.setText(profile.getMinecraftArgs());
|
||||
txtPrecalledCommand.setText(profile.getPrecalledCommand());
|
||||
txtServerIP.setText(profile.getServerIp());
|
||||
chkDebug.setSelected(profile.isDebug());
|
||||
chkNoJVMArgs.setSelected(profile.isNoJVMArgs());
|
||||
chkFullscreen.setSelected(profile.isFullscreen());
|
||||
chkCancelWrapper.setSelected(profile.isCanceledWrapper());
|
||||
cboLauncherVisibility.setSelectedIndex(profile.getLauncherVisibility().ordinal());
|
||||
cboRunDirectory.setSelectedIndex(profile.getGameDirType().ordinal());
|
||||
cboJava.setSelectedIndex(profile.getJavaIndexInAllJavas());
|
||||
@ -1360,8 +1324,6 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
private javax.swing.JComboBox cboProfiles;
|
||||
private javax.swing.JComboBox cboRunDirectory;
|
||||
private javax.swing.JComboBox cboVersions;
|
||||
private javax.swing.JCheckBox chkCancelWrapper;
|
||||
private javax.swing.JCheckBox chkDebug;
|
||||
private javax.swing.JCheckBox chkFullscreen;
|
||||
private javax.swing.JCheckBox chkNoJVMArgs;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.launcher.ui;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import javax.swing.JOptionPane;
|
||||
@ -25,11 +26,13 @@ import org.jackhuang.hellominecraft.launcher.core.launch.GameLauncher;
|
||||
import org.jackhuang.hellominecraft.launcher.core.launch.LaunchingState;
|
||||
import org.jackhuang.hellominecraft.launcher.setting.Profile;
|
||||
import org.jackhuang.hellominecraft.launcher.setting.Settings;
|
||||
import org.jackhuang.hellominecraft.launcher.util.MinecraftCrashAdvicer;
|
||||
import org.jackhuang.hellominecraft.util.C;
|
||||
import org.jackhuang.hellominecraft.util.Event;
|
||||
import org.jackhuang.hellominecraft.util.MessageBox;
|
||||
import org.jackhuang.hellominecraft.util.func.Consumer;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
import org.jackhuang.hellominecraft.util.system.FileUtils;
|
||||
import org.jackhuang.hellominecraft.util.system.JavaProcessMonitor;
|
||||
import org.jackhuang.hellominecraft.util.ui.LogWindow;
|
||||
import org.jackhuang.hellominecraft.util.ui.WebFrame;
|
||||
@ -95,8 +98,20 @@ public class LaunchingUIDaemon {
|
||||
JavaProcessMonitor jpm = new JavaProcessMonitor(p);
|
||||
jpm.applicationExitedAbnormallyEvent.register(t -> {
|
||||
HMCLog.err("The game exited abnormally, exit code: " + t);
|
||||
MessageBox.Show(C.i18n("launch.exited_abnormally") + " exit code: " + t);
|
||||
WebFrame f = new WebFrame(jpm.getJavaProcess().getStdOutLines().toArray(new String[0]));
|
||||
String[] logs = jpm.getJavaProcess().getStdOutLines().toArray(new String[0]);
|
||||
String errorText = null;
|
||||
for (String s : logs) {
|
||||
int pos = s.lastIndexOf("#@!@#");
|
||||
if (pos >= 0 && pos < s.length() - "#@!@#".length() - 1) {
|
||||
errorText = s.substring(pos + "#@!@#".length()).trim();
|
||||
break;
|
||||
}
|
||||
}
|
||||
String msg = C.i18n("launch.exited_abnormally") + " exit code: " + t;
|
||||
if (errorText != null)
|
||||
msg += ", advice: " + MinecraftCrashAdvicer.getAdvice(FileUtils.readFileToStringQuietly(new File(errorText)));
|
||||
MessageBox.Show(msg);
|
||||
WebFrame f = new WebFrame(logs);
|
||||
f.setModal(true);
|
||||
f.setTitle("Game output");
|
||||
f.setVisible(true);
|
||||
@ -123,6 +138,10 @@ public class LaunchingUIDaemon {
|
||||
return true;
|
||||
};
|
||||
|
||||
private static void getCrashReport() {
|
||||
|
||||
}
|
||||
|
||||
private static void checkExit(LauncherVisibility v) {
|
||||
if (v != LauncherVisibility.KEEP && !LogWindow.INSTANCE.isVisible()) {
|
||||
HMCLog.log("Launcher will exit now.");
|
||||
|
@ -32,6 +32,8 @@ public final class MinecraftCrashAdvicer {
|
||||
}
|
||||
|
||||
public static String getAdvice(String trace, boolean selfCrash) {
|
||||
if (trace == null)
|
||||
return C.i18n("crash.advice.no");
|
||||
trace = trace.toLowerCase(SupportedLocales.NOW_LOCALE.self);
|
||||
if (trace.contains("pixel format not accelerated"))
|
||||
return C.i18n("crash.advice.LWJGLException");
|
||||
|
Loading…
Reference in New Issue
Block a user