Fixed #26
This commit is contained in:
@@ -31,6 +31,7 @@ import org.jackhuang.hellominecraft.util.StrUtils;
|
|||||||
import org.jackhuang.hellominecraft.launcher.util.MinecraftCrashAdvicer;
|
import org.jackhuang.hellominecraft.launcher.util.MinecraftCrashAdvicer;
|
||||||
import org.jackhuang.hellominecraft.util.DoubleOutputStream;
|
import org.jackhuang.hellominecraft.util.DoubleOutputStream;
|
||||||
import org.jackhuang.hellominecraft.util.LauncherPrintStream;
|
import org.jackhuang.hellominecraft.util.LauncherPrintStream;
|
||||||
|
import org.jackhuang.hellominecraft.util.Utils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -106,6 +107,7 @@ public final class Launcher {
|
|||||||
|
|
||||||
LOGGER.info("*** Launching Game ***");
|
LOGGER.info("*** Launching Game ***");
|
||||||
|
|
||||||
|
int flag = 0;
|
||||||
try {
|
try {
|
||||||
minecraftMain.invoke(null, new Object[] { (String[]) cmdList.toArray(new String[cmdList.size()]) });
|
minecraftMain.invoke(null, new Object[] { (String[]) cmdList.toArray(new String[cmdList.size()]) });
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
@@ -113,8 +115,15 @@ public final class Launcher {
|
|||||||
System.err.println(C.i18n("crash.minecraft"));
|
System.err.println(C.i18n("crash.minecraft"));
|
||||||
System.err.println(MinecraftCrashAdvicer.getAdvice(trace));
|
System.err.println(MinecraftCrashAdvicer.getAdvice(trace));
|
||||||
System.err.println(trace);
|
System.err.println(trace);
|
||||||
|
flag = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGGER.info("*** Game exited ***");
|
LOGGER.info("*** Game Exited ***");
|
||||||
|
|
||||||
|
try {
|
||||||
|
Utils.shutdownForcely(flag);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.log(Level.SEVERE, "Failed to shut down this process...", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ public final class Main implements Runnable {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
System.setProperty("sun.java2d.noddraw", "true");
|
System.setProperty("sun.java2d.noddraw", "true");
|
||||||
System.setProperty("sun.java2d.apiaware", "false");
|
System.setProperty("sun.java2d.dpiaware", "false");
|
||||||
Thread.setDefaultUncaughtExceptionHandler(new CrashReporter(true));
|
Thread.setDefaultUncaughtExceptionHandler(new CrashReporter(true));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -82,23 +82,31 @@ public class HeaderTab extends JLabel
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mousePressed(MouseEvent e) {
|
public void mousePressed(MouseEvent e) {
|
||||||
|
if (!isEnabled())
|
||||||
|
return;
|
||||||
this.model.setPressed(true);
|
this.model.setPressed(true);
|
||||||
this.model.setArmed(true);
|
this.model.setArmed(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseReleased(MouseEvent e) {
|
public void mouseReleased(MouseEvent e) {
|
||||||
|
if (!isEnabled())
|
||||||
|
return;
|
||||||
this.model.setPressed(false);
|
this.model.setPressed(false);
|
||||||
this.model.setArmed(false);
|
this.model.setArmed(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseEntered(MouseEvent e) {
|
public void mouseEntered(MouseEvent e) {
|
||||||
|
if (!isEnabled())
|
||||||
|
return;
|
||||||
this.model.setRollover(true);
|
this.model.setRollover(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseExited(MouseEvent e) {
|
public void mouseExited(MouseEvent e) {
|
||||||
|
if (!isEnabled())
|
||||||
|
return;
|
||||||
this.model.setRollover(false);
|
this.model.setRollover(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import org.jackhuang.hellominecraft.lookandfeel.comp.ConstomButton;
|
|||||||
import org.jackhuang.hellominecraft.util.func.Consumer;
|
import org.jackhuang.hellominecraft.util.func.Consumer;
|
||||||
import org.jackhuang.hellominecraft.util.system.FileUtils;
|
import org.jackhuang.hellominecraft.util.system.FileUtils;
|
||||||
import org.jackhuang.hellominecraft.util.tasks.TaskWindow;
|
import org.jackhuang.hellominecraft.util.tasks.TaskWindow;
|
||||||
|
import org.jackhuang.hellominecraft.util.ui.SwingUtils;
|
||||||
import org.jackhuang.hellominecraft.util.ui.wizard.api.WizardDisplayer;
|
import org.jackhuang.hellominecraft.util.ui.wizard.api.WizardDisplayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -501,6 +502,8 @@ public class MainPagePanel extends AnimatedPanel {
|
|||||||
isLoading = false;
|
isLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final Consumer<Boolean> launchingStateChanged = t -> SwingUtils.setEnabled(MainFrame.INSTANCE.getRootPane(), !t);
|
||||||
|
|
||||||
final Consumer<String> versionChanged = this::versionChanged;
|
final Consumer<String> versionChanged = this::versionChanged;
|
||||||
|
|
||||||
void versionChanged(String selectedVersion) {
|
void versionChanged(String selectedVersion) {
|
||||||
@@ -513,6 +516,7 @@ public class MainPagePanel extends AnimatedPanel {
|
|||||||
final Consumer<Profile> onSelectedProfilesChanged = t -> {
|
final Consumer<Profile> onSelectedProfilesChanged = t -> {
|
||||||
t.service().version().onRefreshedVersions.register(onRefreshedVersions);
|
t.service().version().onRefreshedVersions.register(onRefreshedVersions);
|
||||||
t.selectedVersionChangedEvent.register(versionChanged);
|
t.selectedVersionChangedEvent.register(versionChanged);
|
||||||
|
t.launcher().launchingStateChanged.register(launchingStateChanged);
|
||||||
|
|
||||||
((DefaultComboBoxModel) cboProfiles.getModel()).setSelectedItem(t.getName());
|
((DefaultComboBoxModel) cboProfiles.getModel()).setSelectedItem(t.getName());
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ public class ModpackInitializationPanel extends javax.swing.JPanel {
|
|||||||
wizardData.put(KEY_INCLUDING_LAUNCHER, chkIncludeLauncher.isSelected());
|
wizardData.put(KEY_INCLUDING_LAUNCHER, chkIncludeLauncher.isSelected());
|
||||||
}//GEN-LAST:event_chkIncludeLauncherItemStateChanged
|
}//GEN-LAST:event_chkIncludeLauncherItemStateChanged
|
||||||
|
|
||||||
static final Pattern PATTERN = Pattern.compile("[-a-zA-Z0-9_\\.\u4E00-\u9FA5]+$");
|
static final Pattern PATTERN = Pattern.compile("[-a-zA-Z0-9_\\.\\(\\)\\[\\]\\{\\}\\<\\>\"\'\u4E00-\u9FA5]+$");
|
||||||
|
|
||||||
void checkProblem() {
|
void checkProblem() {
|
||||||
controller.setProblem(null);
|
controller.setProblem(null);
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ import org.jackhuang.hellominecraft.util.C;
|
|||||||
import org.jackhuang.hellominecraft.util.Pair;
|
import org.jackhuang.hellominecraft.util.Pair;
|
||||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||||
import org.jackhuang.hellominecraft.util.Utils;
|
import org.jackhuang.hellominecraft.util.Utils;
|
||||||
import org.jackhuang.hellominecraft.util.func.CallbackIO;
|
|
||||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||||
import org.jackhuang.hellominecraft.util.system.ZipEngine;
|
import org.jackhuang.hellominecraft.util.system.ZipEngine;
|
||||||
import org.jackhuang.hellominecraft.util.ui.WebPage;
|
import org.jackhuang.hellominecraft.util.ui.WebPage;
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler {
|
|||||||
if (THROWABLE_SET.contains(stacktrace))
|
if (THROWABLE_SET.contains(stacktrace))
|
||||||
return;
|
return;
|
||||||
THROWABLE_SET.add(stacktrace);
|
THROWABLE_SET.add(stacktrace);
|
||||||
new Thread(() -> {
|
Thread t = new Thread(() -> {
|
||||||
HashMap<String, String> map = new HashMap<>();
|
HashMap<String, String> map = new HashMap<>();
|
||||||
map.put("CrashReport", text);
|
map.put("CrashReport", text);
|
||||||
try {
|
try {
|
||||||
@@ -139,7 +139,9 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler {
|
|||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
LOGGER.log(Level.SEVERE, "Failed to post HMCL server.", ex);
|
LOGGER.log(Level.SEVERE, "Failed to post HMCL server.", ex);
|
||||||
}
|
}
|
||||||
}).start();
|
});
|
||||||
|
t.setDaemon(true);
|
||||||
|
t.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import org.jackhuang.hellominecraft.launcher.core.launch.LaunchOptions;
|
|||||||
import org.jackhuang.hellominecraft.launcher.setting.Profile;
|
import org.jackhuang.hellominecraft.launcher.setting.Profile;
|
||||||
import org.jackhuang.hellominecraft.launcher.setting.Settings;
|
import org.jackhuang.hellominecraft.launcher.setting.Settings;
|
||||||
import org.jackhuang.hellominecraft.util.C;
|
import org.jackhuang.hellominecraft.util.C;
|
||||||
|
import org.jackhuang.hellominecraft.util.EventHandler;
|
||||||
import org.jackhuang.hellominecraft.util.func.Consumer;
|
import org.jackhuang.hellominecraft.util.func.Consumer;
|
||||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||||
|
|
||||||
@@ -41,31 +42,39 @@ public class HMCLGameLauncher {
|
|||||||
Profile profile;
|
Profile profile;
|
||||||
boolean isLaunching = false;
|
boolean isLaunching = false;
|
||||||
|
|
||||||
|
public final EventHandler<Boolean> launchingStateChanged = new EventHandler<>(this);
|
||||||
|
|
||||||
public HMCLGameLauncher(Profile p) {
|
public HMCLGameLauncher(Profile p) {
|
||||||
this.profile = p;
|
this.profile = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setLaunching(boolean isLaunching) {
|
||||||
|
if (isLaunching != this.isLaunching)
|
||||||
|
launchingStateChanged.execute(isLaunching);
|
||||||
|
this.isLaunching = isLaunching;
|
||||||
|
}
|
||||||
|
|
||||||
public void genLaunchCode(final Consumer<GameLauncher> listener, final Consumer<String> failed, String passwordIfNeeded) {
|
public void genLaunchCode(final Consumer<GameLauncher> listener, final Consumer<String> failed, String passwordIfNeeded) {
|
||||||
if (isLaunching || profile == null)
|
if (isLaunching || profile == null)
|
||||||
return;
|
return;
|
||||||
isLaunching = true;
|
setLaunching(true);
|
||||||
HMCLog.log("Start generating launching command...");
|
HMCLog.log("Start generating launching command...");
|
||||||
File file = profile.getCanonicalGameDirFile();
|
File file = profile.getCanonicalGameDirFile();
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
failed.accept(C.i18n("minecraft.wrong_path"));
|
failed.accept(C.i18n("minecraft.wrong_path"));
|
||||||
isLaunching = false;
|
setLaunching(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (profile.getSelectedVersion() == null) {
|
if (profile.getSelectedVersion() == null) {
|
||||||
failed.accept(C.i18n("minecraft.no_selected_version"));
|
failed.accept(C.i18n("minecraft.no_selected_version"));
|
||||||
isLaunching = false;
|
setLaunching(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final IAuthenticator l = IAuthenticator.LOGINS.get(Settings.getInstance().getLoginType());
|
final IAuthenticator l = IAuthenticator.LOGINS.get(Settings.getInstance().getLoginType());
|
||||||
final LoginInfo li = new LoginInfo(l.getUserName(), l.isLoggedIn() || !l.hasPassword() ? null : passwordIfNeeded);
|
final LoginInfo li = new LoginInfo(l.getUserName(), l.isLoggedIn() || !l.hasPassword() ? null : passwordIfNeeded);
|
||||||
new Thread() {
|
Thread t = new Thread() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Thread.currentThread().setName("Game Launcher");
|
Thread.currentThread().setName("Game Launcher");
|
||||||
@@ -74,18 +83,20 @@ public class HMCLGameLauncher {
|
|||||||
PluginManager.plugin().onProcessingLaunchOptions(options);
|
PluginManager.plugin().onProcessingLaunchOptions(options);
|
||||||
DefaultGameLauncher gl = new DefaultGameLauncher(options, profile.service(), li, l);
|
DefaultGameLauncher gl = new DefaultGameLauncher(options, profile.service(), li, l);
|
||||||
gl.setTag(profile.getSelectedVersionSetting().getLauncherVisibility());
|
gl.setTag(profile.getSelectedVersionSetting().getLauncherVisibility());
|
||||||
gl.successEvent.register(() -> isLaunching = false);
|
gl.successEvent.register(() -> setLaunching(false));
|
||||||
listener.accept(gl);
|
listener.accept(gl);
|
||||||
gl.makeLaunchCommand();
|
gl.makeLaunchCommand();
|
||||||
} catch (GameException e) {
|
} catch (GameException e) {
|
||||||
failed.accept(C.i18n("launch.failed") + ", " + e.getMessage());
|
failed.accept(C.i18n("launch.failed") + ", " + e.getMessage());
|
||||||
isLaunching = false;
|
setLaunching(false);
|
||||||
} catch (AuthenticationException e) {
|
} catch (AuthenticationException e) {
|
||||||
failed.accept(C.i18n("login.failed") + ", " + e.getMessage());
|
failed.accept(C.i18n("login.failed") + ", " + e.getMessage());
|
||||||
isLaunching = false;
|
setLaunching(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.start();
|
};
|
||||||
|
t.setDaemon(true);
|
||||||
|
t.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hellominecraft.util.ui;
|
package org.jackhuang.hellominecraft.util.ui;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
import java.awt.EventQueue;
|
import java.awt.EventQueue;
|
||||||
import java.awt.FontMetrics;
|
import java.awt.FontMetrics;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -27,6 +28,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.swing.DefaultListModel;
|
import javax.swing.DefaultListModel;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JList;
|
import javax.swing.JList;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
@@ -265,4 +267,13 @@ public class SwingUtils {
|
|||||||
return -1;
|
return -1;
|
||||||
return ((JComboBox) msgs[1]).getSelectedIndex();
|
return ((JComboBox) msgs[1]).getSelectedIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setEnabled(JComponent component, boolean t) {
|
||||||
|
synchronized (component.getTreeLock()) {
|
||||||
|
for (Component c : component.getComponents())
|
||||||
|
if (c instanceof JComponent)
|
||||||
|
setEnabled((JComponent) c, t);
|
||||||
|
}
|
||||||
|
component.setEnabled(t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -460,6 +460,7 @@ public class WizardDisplayerImpl extends WizardDisplayer {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
Thread runner = new Thread(run, "Wizard Background Result Thread " + r);
|
Thread runner = new Thread(run, "Wizard Background Result Thread " + r);
|
||||||
|
runner.setDaemon(true);
|
||||||
runner.start();
|
runner.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user