Fixed typesafe again and again

This commit is contained in:
huangyuhui
2017-02-24 12:57:18 +08:00
parent 44735b3d4e
commit 0bda79c0d5
7 changed files with 32 additions and 22 deletions

View File

@@ -1015,7 +1015,7 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
private void btnTestGameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTestGameActionPerformed
LogWindow.INSTANCE.setVisible(true);
MainFrame.INSTANCE.daemon.runGame(Settings.getLastProfile());
MainFrame.INSTANCE.daemon.testGame(Settings.getLastProfile());
}//GEN-LAST:event_btnTestGameActionPerformed
private void btnExploreMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnExploreMouseClicked

View File

@@ -89,22 +89,26 @@ public class LaunchingUIDaemon {
break;
}
}
String msg = C.i18n("launch.exited_abnormally") + " exit code: " + exitCode;
if (errorText != null)
msg += ", advice: " + MinecraftCrashAdvicer.getAdvice(FileUtils.readQuietly(new File(errorText)));
WebFrame f = new WebFrame(logs);
f.setModal(true);
f.setTitle(msg);
f.setVisible(true);
if (!LogWindow.INSTANCE.isVisible()) {
String msg = C.i18n("launch.exited_abnormally") + " exit code: " + exitCode;
if (errorText != null)
msg += ", advice: " + MinecraftCrashAdvicer.getAdvice(FileUtils.readQuietly(new File(errorText)));
WebFrame f = new WebFrame(logs);
f.setModal(true);
f.setTitle(msg);
f.setVisible(true);
}
checkExit((LauncherVisibility) ((ProcessMonitor) event.getSource()).getTag());
});
HMCLApi.EVENT_BUS.channel(JVMLaunchFailedEvent.class).register(event -> {
int exitCode = event.getValue().getExitCode();
HMCLog.err("Cannot create jvm, exit code: " + exitCode);
WebFrame f = new WebFrame(event.getValue().getStdOutLines().toArray(new String[0]));
f.setModal(true);
f.setTitle(C.i18n("launch.cannot_create_jvm") + " exit code: " + exitCode);
f.setVisible(true);
if (!LogWindow.INSTANCE.isVisible()) {
WebFrame f = new WebFrame(event.getValue().getStdOutLines().toArray(new String[0]));
f.setModal(true);
f.setTitle(C.i18n("launch.cannot_create_jvm") + " exit code: " + exitCode);
f.setVisible(true);
}
checkExit((LauncherVisibility) ((ProcessMonitor) event.getSource()).getTag());
});
}
@@ -117,6 +121,15 @@ public class LaunchingUIDaemon {
}, MainFrame.INSTANCE::failed, Settings.getInstance().getAuthenticator().getPassword());
}
void testGame(Profile profile) {
MainFrame.INSTANCE.showMessage(C.i18n("ui.message.launching"));
profile.launcher().genLaunchCode(value -> {
DefaultPlugin.INSTANCE.saveAuthenticatorConfig();
((HMCLGameLauncher.GameLauncherTag) value.getTag()).state = 1;
((HMCLGameLauncher.GameLauncherTag) value.getTag()).launcherVisibility = LauncherVisibility.KEEP;
}, MainFrame.INSTANCE::failed, Settings.getInstance().getAuthenticator().getPassword());
}
void makeLaunchScript(Profile profile) {
MainFrame.INSTANCE.showMessage(C.i18n("ui.message.launching"));
profile.launcher().genLaunchCode(value -> {

View File

@@ -44,7 +44,7 @@ public class LogWindowOutputStream extends OutputStream {
@Override
public final void write(byte[] arr, int off, int len) {
append(new String(arr, off, len, Charsets.UTF_8));
append(new String(arr, off, len));
}
private void append(final String str) {
@@ -55,6 +55,6 @@ public class LogWindowOutputStream extends OutputStream {
@Override
public final void write(int i) {
append(new String(new byte[] { (byte) i }, Charsets.UTF_8));
append(new String(new byte[] { (byte) i }));
}
}