Fixed #33
This commit is contained in:
@@ -81,7 +81,6 @@ public abstract class AbstractMinecraftLoader implements IMinecraftLoader {
|
||||
if (OS.os() == OS.WINDOWS)
|
||||
res.add("-XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump");
|
||||
res.add("-XX:+UseConcMarkSweepGC");
|
||||
res.add("-XX:+CMSIncrementalMode");
|
||||
res.add("-XX:-UseAdaptiveSizePolicy");
|
||||
res.add("-XX:-OmitStackTraceInFastThrow");
|
||||
res.add("-Xincgc");
|
||||
|
||||
@@ -53,10 +53,11 @@ public class GameLauncher {
|
||||
LoginInfo info;
|
||||
UserProfileProvider result;
|
||||
IAuthenticator login;
|
||||
public final EventHandler<List<DownloadLibraryJob>> downloadLibrariesEvent = new EventHandler(this);
|
||||
public final EventHandler<List<String>> successEvent = new EventHandler(this);
|
||||
public final EventHandler<JavaProcess> launchEvent = new EventHandler(this);
|
||||
public final EventHandler<DecompressLibraryJob> decompressNativesEvent = new EventHandler(this);
|
||||
public final EventHandler<List<DownloadLibraryJob>> downloadLibrariesEvent = new EventHandler<>(this);
|
||||
public final EventHandler<List<String>> successEvent = new EventHandler<>(this);
|
||||
public final EventHandler<JavaProcess> launchEvent = new EventHandler<>(this);
|
||||
public final EventHandler<LaunchingState> launchingStateChangedEvent = new EventHandler<>(this);
|
||||
public final EventHandler<DecompressLibraryJob> decompressNativesEvent = new EventHandler<>(this);
|
||||
|
||||
public GameLauncher(LaunchOptions options, IMinecraftService version, LoginInfo info, IAuthenticator lg) {
|
||||
this.options = options;
|
||||
@@ -78,6 +79,7 @@ public class GameLauncher {
|
||||
public IMinecraftLoader makeLaunchCommand() throws AuthenticationException, GameException {
|
||||
HMCLog.log("Building process");
|
||||
HMCLog.log("Logging in...");
|
||||
launchingStateChangedEvent.execute(LaunchingState.LoggingIn);
|
||||
IMinecraftLoader loader;
|
||||
if (info != null)
|
||||
result = login.login(info);
|
||||
@@ -87,6 +89,7 @@ public class GameLauncher {
|
||||
throw new AuthenticationException("Result can not be null.");
|
||||
PluginManager.plugin().onProcessingLoginResult(result);
|
||||
|
||||
launchingStateChangedEvent.execute(LaunchingState.GeneratingLaunchingCodes);
|
||||
loader = service.launch(options, result);
|
||||
|
||||
File file = service.version().getDecompressNativesToLocation(loader.getMinecraftVersion());
|
||||
@@ -94,10 +97,12 @@ public class GameLauncher {
|
||||
FileUtils.cleanDirectoryQuietly(file);
|
||||
|
||||
HMCLog.log("Detecting libraries...");
|
||||
launchingStateChangedEvent.execute(LaunchingState.DownloadingLibraries);
|
||||
if (!downloadLibrariesEvent.execute(service.download().getDownloadLibraries(loader.getMinecraftVersion())))
|
||||
throw new GameException("Failed to download libraries");
|
||||
|
||||
HMCLog.log("Unpacking natives...");
|
||||
launchingStateChangedEvent.execute(LaunchingState.DecompressingNatives);
|
||||
DecompressLibraryJob job = service.version().getDecompressLibraries(loader.getMinecraftVersion());
|
||||
if (!decompressNativesEvent.execute(job))
|
||||
throw new GameException("Failed to decompress natives");
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.core.launch;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public enum LaunchingState {
|
||||
LoggingIn,
|
||||
GeneratingLaunchingCodes,
|
||||
DownloadingLibraries,
|
||||
DecompressingNatives
|
||||
}
|
||||
@@ -99,18 +99,26 @@ public class AnimatedPanel extends JPanel implements Selectable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSelected() {
|
||||
public void onSelect() {
|
||||
if (!selected)
|
||||
animate();
|
||||
selected = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLeaving() {
|
||||
public void onLeave() {
|
||||
selected = false;
|
||||
}
|
||||
|
||||
boolean created = false;
|
||||
|
||||
@Override
|
||||
public void onCreated() {
|
||||
public void onCreate() {
|
||||
created = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCreated() {
|
||||
return created;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,8 +130,8 @@ public class GameDownloadPanel extends AnimatedPanel {
|
||||
boolean refreshedDownloads = false;
|
||||
|
||||
@Override
|
||||
public void onSelected() {
|
||||
super.onSelected();
|
||||
public void onSelect() {
|
||||
super.onSelect();
|
||||
if (!refreshedDownloads) {
|
||||
refreshedDownloads = true;
|
||||
refreshDownloads();
|
||||
|
||||
@@ -81,16 +81,18 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
/**
|
||||
* Creates new form GameSettingsPanel
|
||||
*/
|
||||
public GameSettingsPanel() {
|
||||
public GameSettingsPanel(MainFrame mf) {
|
||||
mf.actions.put("showGameDownloads", () -> {
|
||||
MainFrame.INSTANCE.selectTab("game");
|
||||
showGameDownloads();
|
||||
});
|
||||
}
|
||||
|
||||
void initGui() {
|
||||
initComponents();
|
||||
setBackground(Color.white);
|
||||
setOpaque(true);
|
||||
|
||||
MainFrame.INSTANCE.actions.put("showGameDownloads", () -> {
|
||||
MainFrame.INSTANCE.selectTab("game");
|
||||
showGameDownloads();
|
||||
});
|
||||
|
||||
for (int i = 0; i < InstallerType.values().length; i++)
|
||||
installerPanels[i] = new InstallerPanel(this, InstallerType.values()[i]);
|
||||
pnlGameDownloads = new GameDownloadPanel(this);
|
||||
@@ -1010,10 +1012,10 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
int idx = cboJava.getSelectedIndex();
|
||||
if (idx != -1) {
|
||||
Java j = Java.JAVA.get(idx);
|
||||
txtJavaDir.setText(j.getHome() == null ? Settings.getLastProfile().getSelectedVersionSetting().getSettingsJavaDir() : j.getJava());
|
||||
txtJavaDir.setEnabled(idx == 1);
|
||||
if (!isLoading)
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setJava(j);
|
||||
txtJavaDir.setEnabled(idx == 1);
|
||||
txtJavaDir.setText(j.getHome() == null ? Settings.getLastProfile().getSelectedVersionSetting().getSettingsJavaDir() : j.getJava());
|
||||
}
|
||||
}//GEN-LAST:event_cboJavaItemStateChanged
|
||||
|
||||
@@ -1177,7 +1179,6 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
txtPermSize.setText(profile.getPermSize());
|
||||
txtJavaArgs.setText(profile.getJavaArgs());
|
||||
txtMinecraftArgs.setText(profile.getMinecraftArgs());
|
||||
txtJavaDir.setText(profile.getSettingsJavaDir());
|
||||
txtPrecalledCommand.setText(profile.getPrecalledCommand());
|
||||
txtServerIP.setText(profile.getServerIp());
|
||||
chkDebug.setSelected(profile.isDebug());
|
||||
@@ -1292,13 +1293,15 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreated() {
|
||||
super.onCreated();
|
||||
public void onCreate() {
|
||||
initGui();
|
||||
|
||||
super.onCreate();
|
||||
Settings.onProfileLoading();
|
||||
}
|
||||
|
||||
public void onLeaving() {
|
||||
super.onLeaving();
|
||||
public void onLeave() {
|
||||
super.onLeave();
|
||||
save();
|
||||
}
|
||||
|
||||
@@ -1376,7 +1379,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
private javax.swing.JTextField txtWidth;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
private final javax.swing.JPanel pnlGameDownloads;
|
||||
private javax.swing.JPanel pnlGameDownloads;
|
||||
// </editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapesd" desc="Profiles & Versions Loading">
|
||||
@@ -1410,7 +1413,12 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
|
||||
public void versionChanged(String version) {
|
||||
isLoading = true;
|
||||
((DefaultComboBoxModel) cboVersions.getModel()).setSelectedItem(version);
|
||||
DefaultComboBoxModel model = (DefaultComboBoxModel) cboVersions.getModel();
|
||||
for (int i = 0; i < model.getSize(); ++i)
|
||||
if (model.getElementAt(i).equals(version)) {
|
||||
model.setSelectedItem(version);
|
||||
break;
|
||||
}
|
||||
cboVersions.setToolTipText(version);
|
||||
|
||||
this.mcVersion = version;
|
||||
@@ -1426,8 +1434,13 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
t.service().version().onRefreshedVersions.register(onRefreshedVersions);
|
||||
t.selectedVersionChangedEvent.register(selectedVersionChangedEvent);
|
||||
|
||||
((DefaultComboBoxModel) cboProfiles.getModel()).setSelectedItem(t.getName());
|
||||
txtGameDir.setText(t.getGameDir());
|
||||
DefaultComboBoxModel model = (DefaultComboBoxModel) cboProfiles.getModel();
|
||||
for (int i = 0; i < model.getSize(); ++i)
|
||||
if (model.getElementAt(i).equals(t.getName())) {
|
||||
model.setSelectedItem(t.getName());
|
||||
break;
|
||||
}
|
||||
};
|
||||
//</editor-fold>
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ public class InstallerPanel extends AnimatedPanel {
|
||||
boolean refreshed = false;
|
||||
|
||||
@Override
|
||||
public void onSelected() {
|
||||
public void onSelect() {
|
||||
if (!refreshed) {
|
||||
refreshVersions();
|
||||
refreshed = true;
|
||||
|
||||
@@ -41,6 +41,9 @@ public class LauncherSettingsPanel extends AnimatedPanel {
|
||||
* Creates new form LancherSettingsPanel
|
||||
*/
|
||||
public LauncherSettingsPanel() {
|
||||
}
|
||||
|
||||
void initGui() {
|
||||
initComponents();
|
||||
|
||||
DefaultComboBoxModel d = new DefaultComboBoxModel();
|
||||
@@ -73,6 +76,12 @@ public class LauncherSettingsPanel extends AnimatedPanel {
|
||||
setOpaque(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
initGui();
|
||||
super.onCreate();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
|
||||
@@ -22,11 +22,13 @@ import java.util.List;
|
||||
import javax.swing.JOptionPane;
|
||||
import org.jackhuang.hellominecraft.launcher.util.LauncherVisibility;
|
||||
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.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.JavaProcessMonitor;
|
||||
import org.jackhuang.hellominecraft.util.ui.LogWindow;
|
||||
@@ -43,6 +45,7 @@ public class LaunchingUIDaemon {
|
||||
void runGame(Profile profile) {
|
||||
MainFrame.INSTANCE.showMessage(C.i18n("ui.message.launching"));
|
||||
profile.launcher().genLaunchCode(value -> {
|
||||
value.launchingStateChangedEvent.register(LAUNCHING_STATE_CHANGED);
|
||||
value.successEvent.register(LAUNCH_FINISHER);
|
||||
value.successEvent.register(customizedSuccessEvent);
|
||||
}, MainFrame.INSTANCE::failed, Settings.getInstance().getAuthenticator().getPassword());
|
||||
@@ -51,11 +54,31 @@ public class LaunchingUIDaemon {
|
||||
void makeLaunchScript(Profile profile) {
|
||||
MainFrame.INSTANCE.showMessage(C.i18n("ui.message.launching"));
|
||||
profile.launcher().genLaunchCode(value -> {
|
||||
value.launchingStateChangedEvent.register(LAUNCHING_STATE_CHANGED);
|
||||
value.successEvent.register(LAUNCH_SCRIPT_FINISHER);
|
||||
value.successEvent.register(customizedSuccessEvent);
|
||||
}, MainFrame.INSTANCE::failed, Settings.getInstance().getAuthenticator().getPassword());
|
||||
}
|
||||
|
||||
private static final Consumer<LaunchingState> LAUNCHING_STATE_CHANGED = t -> {
|
||||
String message = null;
|
||||
switch (t) {
|
||||
case LoggingIn:
|
||||
message = "launch.state.logging_in";
|
||||
break;
|
||||
case GeneratingLaunchingCodes:
|
||||
message = "launch.state.generating_launching_codes";
|
||||
break;
|
||||
case DownloadingLibraries:
|
||||
message = "launch.state.downloading_libraries";
|
||||
break;
|
||||
case DecompressingNatives:
|
||||
message = "launch.state.decompressing_natives";
|
||||
break;
|
||||
}
|
||||
MainFrame.INSTANCE.showMessage(C.i18n(message));
|
||||
};
|
||||
|
||||
private static final Event<List<String>> LAUNCH_FINISHER = (sender, str) -> {
|
||||
final GameLauncher obj = (GameLauncher) sender;
|
||||
obj.launchEvent.register(p -> {
|
||||
|
||||
@@ -175,9 +175,9 @@ public final class MainFrame extends DraggableFrame {
|
||||
|
||||
header.add(Box.createRigidArea(new Dimension(8, 0)));
|
||||
|
||||
initializeTab(MainPagePanel.class, "main");
|
||||
initializeTab(GameSettingsPanel.class, "game");
|
||||
initializeTab(LauncherSettingsPanel.class, "launcher");
|
||||
initializeTab(new MainPagePanel(), "main");
|
||||
initializeTab(new GameSettingsPanel(this), "game");
|
||||
initializeTab(new LauncherSettingsPanel(), "launcher");
|
||||
|
||||
header.add(Box.createHorizontalGlue());
|
||||
|
||||
@@ -231,7 +231,6 @@ public final class MainFrame extends DraggableFrame {
|
||||
this.infoSwap.setOpaque(false);
|
||||
|
||||
tabWrapper = new JPanel[tabHeader.size()];
|
||||
tabContent = new AnimatedPanel[tabHeader.size()];
|
||||
for (int i = 0; i < tabHeader.size(); i++) {
|
||||
tabWrapper[i] = new JPanel();
|
||||
tabWrapper[i].setLayout(new GridLayout());
|
||||
@@ -251,7 +250,7 @@ public final class MainFrame extends DraggableFrame {
|
||||
|
||||
private final ActionListener tabListener = e -> MainFrame.this.selectTab(e.getActionCommand());
|
||||
|
||||
private void initializeTab(Class<? extends AnimatedPanel> c, String cmd) {
|
||||
private void initializeTab(AnimatedPanel inst, String cmd) {
|
||||
HeaderTab tab = new HeaderTab(C.i18n("launcher.title." + cmd));
|
||||
tab.setActionCommand(cmd);
|
||||
tab.setForeground(BasicColors.COLOR_WHITE_TEXT);
|
||||
@@ -260,57 +259,51 @@ public final class MainFrame extends DraggableFrame {
|
||||
tab.addActionListener(tabListener);
|
||||
header.add(tab);
|
||||
tabHeader.add(tab);
|
||||
tabClasses.add(c);
|
||||
tabContent.add(inst);
|
||||
}
|
||||
|
||||
private List<HeaderTab> tabHeader = new ArrayList<>();
|
||||
private List<Class<? extends AnimatedPanel>> tabClasses = new ArrayList<>();
|
||||
private final List<HeaderTab> tabHeader = new ArrayList<>();
|
||||
private JPanel tabWrapper[];
|
||||
private AnimatedPanel tabContent[];
|
||||
private final List<AnimatedPanel> tabContent = new ArrayList<>();
|
||||
|
||||
public void selectTab(String tabName) {
|
||||
int chosen = -1;
|
||||
AnimatedPanel onCreate = null, onSelect = null;
|
||||
for (int i = 0; i < tabHeader.size(); i++)
|
||||
if (tabName.equalsIgnoreCase(tabHeader.get(i).getActionCommand())) {
|
||||
if (tabContent[i] == null) {
|
||||
try {
|
||||
tabContent[i] = tabClasses.get(i).newInstance();
|
||||
onCreate = tabContent[i];
|
||||
} catch (Exception mustnothappen) {
|
||||
throw new Error(mustnothappen);
|
||||
}
|
||||
tabWrapper[i].add(tabContent[i]);
|
||||
} else if (tabContent[i].isSelected())
|
||||
if (!tabContent.get(i).isCreated()) {
|
||||
onCreate = tabContent.get(i);
|
||||
tabWrapper[i].add(tabContent.get(i));
|
||||
} else if (tabContent.get(i).isSelected())
|
||||
continue;
|
||||
chosen = i;
|
||||
break;
|
||||
}
|
||||
if (chosen != -1) {
|
||||
for (int i = 0; i < tabHeader.size(); i++)
|
||||
if (i != chosen && tabContent[i] != null && tabContent[i].isSelected())
|
||||
tabContent[i].onLeaving();
|
||||
if (i != chosen && tabContent.get(i) != null && tabContent.get(i).isSelected())
|
||||
tabContent.get(i).onLeave();
|
||||
for (int i = 0; i < tabHeader.size(); i++)
|
||||
if (i == chosen) {
|
||||
for (int j = 0; j < tabHeader.size(); j++)
|
||||
if (j != i)
|
||||
tabHeader.get(j).setIsActive(false);
|
||||
tabHeader.get(i).setIsActive(true);
|
||||
onSelect = tabContent[i];
|
||||
onSelect = tabContent.get(i);
|
||||
}
|
||||
|
||||
this.infoLayout.show(this.infoSwap, tabName);
|
||||
if (onCreate != null)
|
||||
onCreate.onCreated();
|
||||
onCreate.onCreate();
|
||||
if (onSelect != null)
|
||||
onSelect.onSelected();
|
||||
onSelect.onSelect();
|
||||
}
|
||||
}
|
||||
|
||||
protected void closing() {
|
||||
for (int i = 0; i < tabHeader.size(); i++)
|
||||
if (tabContent[i] != null && tabContent[i].isSelected())
|
||||
tabContent[i].onLeaving();
|
||||
if (tabContent.get(i) != null && tabContent.get(i).isSelected())
|
||||
tabContent.get(i).onLeave();
|
||||
}
|
||||
|
||||
protected void closeWindow() {
|
||||
@@ -467,7 +460,7 @@ public final class MainFrame extends DraggableFrame {
|
||||
|
||||
LaunchingUIDaemon daemon = new LaunchingUIDaemon();
|
||||
|
||||
HashMap<String, Runnable> actions = new HashMap<>();
|
||||
final HashMap<String, Runnable> actions = new HashMap<>();
|
||||
|
||||
void invokeAction(String name) {
|
||||
if (actions.containsKey(name))
|
||||
|
||||
@@ -56,6 +56,9 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
* Creates new form MainPagePanel
|
||||
*/
|
||||
public MainPagePanel() {
|
||||
}
|
||||
|
||||
void initGui() {
|
||||
initComponents();
|
||||
|
||||
pnlButtons = new javax.swing.JPanel();
|
||||
@@ -411,14 +414,15 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
// <editor-fold defaultstate="collapsed" desc="Private Variables">
|
||||
boolean preparingAuth = true;
|
||||
private boolean isLoading = false;
|
||||
private final javax.swing.JPanel pnlButtons;
|
||||
private final ConstomButton btnRun;
|
||||
private javax.swing.JPanel pnlButtons;
|
||||
private ConstomButton btnRun;
|
||||
private static final int DEFAULT_WIDTH = 800, DEFAULT_HEIGHT = 480;
|
||||
//</editor-fold>
|
||||
|
||||
@Override
|
||||
public void onCreated() {
|
||||
super.onCreated();
|
||||
public void onCreate() {
|
||||
initGui();
|
||||
super.onCreate();
|
||||
Settings.onProfileLoading();
|
||||
}
|
||||
|
||||
@@ -485,12 +489,13 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
cboVersions.removeAllItems();
|
||||
String selVersion = Settings.getLastProfile().getSelectedVersion();
|
||||
if (Settings.getLastProfile().service().version().getVersions().isEmpty()) {
|
||||
if (!showedNoVersion)
|
||||
if (!showedNoVersion) {
|
||||
showedNoVersion = true;
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
if (MessageBox.Show(C.i18n("mainwindow.no_version"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
|
||||
MainFrame.INSTANCE.invokeAction("showGameDownloads");
|
||||
showedNoVersion = true;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
for (MinecraftVersion mcVersion : Settings.getLastProfile().service().version().getVersions()) {
|
||||
if (mcVersion.hidden)
|
||||
@@ -508,7 +513,12 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
|
||||
void versionChanged(String selectedVersion) {
|
||||
isLoading = true;
|
||||
((DefaultComboBoxModel) cboVersions.getModel()).setSelectedItem(selectedVersion);
|
||||
DefaultComboBoxModel model = (DefaultComboBoxModel) cboVersions.getModel();
|
||||
for (int i = 0; i < model.getSize(); ++i)
|
||||
if (model.getElementAt(i).equals(selectedVersion)) {
|
||||
model.setSelectedItem(selectedVersion);
|
||||
break;
|
||||
}
|
||||
cboVersions.setToolTipText(selectedVersion);
|
||||
isLoading = false;
|
||||
}
|
||||
@@ -518,6 +528,11 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
t.selectedVersionChangedEvent.register(versionChanged);
|
||||
t.launcher().launchingStateChanged.register(launchingStateChanged);
|
||||
|
||||
((DefaultComboBoxModel) cboProfiles.getModel()).setSelectedItem(t.getName());
|
||||
DefaultComboBoxModel model = (DefaultComboBoxModel) cboProfiles.getModel();
|
||||
for (int i = 0; i < model.getSize(); ++i)
|
||||
if (model.getElementAt(i).equals(t.getName())) {
|
||||
model.setSelectedItem(t.getName());
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -38,8 +38,11 @@ public class NewTabPane extends JTabbedPane implements ChangeListener {
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
if (initializing)
|
||||
return;
|
||||
for (int i = 0; i < getComponentCount(); ++i)
|
||||
if (getSelectedIndex() != i && getComponent(i) instanceof Selectable)
|
||||
((Selectable) getComponent(i)).onLeave();
|
||||
if (getSelectedComponent() instanceof Selectable)
|
||||
((Selectable) getSelectedComponent()).onSelected();
|
||||
((Selectable) getSelectedComponent()).onSelect();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,11 +23,13 @@ package org.jackhuang.hellominecraft.launcher.ui;
|
||||
*/
|
||||
public interface Selectable {
|
||||
|
||||
void onCreated();
|
||||
void onCreate();
|
||||
|
||||
void onSelected();
|
||||
boolean isCreated();
|
||||
|
||||
void onSelect();
|
||||
|
||||
boolean isSelected();
|
||||
|
||||
void onLeaving();
|
||||
void onLeave();
|
||||
}
|
||||
|
||||
@@ -92,8 +92,9 @@ public class Java {
|
||||
*/
|
||||
public static List<Java> queryAllJDKInMac() {
|
||||
List<Java> ans = new ArrayList<>();
|
||||
if (new File("/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home").exists())
|
||||
ans.add(new Java("JRE", "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home"));
|
||||
File jre = new File("/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home");
|
||||
if (jre.exists())
|
||||
ans.add(new Java("JRE", jre.getPath()));
|
||||
File f = new File("/Library/Java/JavaVirtualMachines/");
|
||||
if (f.exists())
|
||||
for (File a : f.listFiles())
|
||||
@@ -109,36 +110,28 @@ public class Java {
|
||||
public static List<Java> queryAllJavaHomeInWindowsByReg() {
|
||||
List<Java> ans = new ArrayList<>();
|
||||
try {
|
||||
List<String> javas = queryRegSubFolders("HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment");
|
||||
for (String java : javas) {
|
||||
int s = 0;
|
||||
for (char c : java.toCharArray())
|
||||
if (c == '.')
|
||||
s++;
|
||||
if (s <= 1)
|
||||
continue;
|
||||
String javahome = queryRegValue(java, "JavaHome");
|
||||
if (javahome != null)
|
||||
ans.add(new Java(java.substring("HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\".length()), javahome));
|
||||
}
|
||||
javas = queryRegSubFolders("HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit");
|
||||
for (String java : javas) {
|
||||
int s = 0;
|
||||
for (char c : java.toCharArray())
|
||||
if (c == '.')
|
||||
s++;
|
||||
if (s <= 1)
|
||||
continue;
|
||||
String javahome = queryRegValue(java, "JavaHome");
|
||||
if (javahome != null)
|
||||
ans.add(new Java(java.substring("HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\".length()), javahome));
|
||||
}
|
||||
queryJava(ans, "HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment");
|
||||
queryJava(ans, "HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit");
|
||||
} catch (IOException | InterruptedException ex) {
|
||||
HMCLog.err("Faield to query java", ex);
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
private static void queryJava(List<Java> ans, String location) throws IOException, InterruptedException {
|
||||
for (String java : queryRegSubFolders(location)) {
|
||||
int s = 0;
|
||||
for (char c : java.toCharArray())
|
||||
if (c == '.')
|
||||
++s;
|
||||
if (s <= 1)
|
||||
continue;
|
||||
String javahome = queryRegValue(java, "JavaHome");
|
||||
if (javahome != null)
|
||||
ans.add(new Java(java.substring(location.length()), javahome));
|
||||
}
|
||||
}
|
||||
|
||||
private static List<String> queryRegSubFolders(String location) throws IOException, InterruptedException {
|
||||
String[] cmd = new String[] { "cmd", "/c", "reg", "query", location };
|
||||
List<String> l = IOUtils.readProcessByInputStream(cmd);
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jackhuang.hellominecraft.util.ui;
|
||||
|
||||
import java.awt.Frame;
|
||||
import java.awt.HeadlessException;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowListener;
|
||||
import java.util.List;
|
||||
@@ -38,35 +39,11 @@ public class WebFrame extends JFrame {
|
||||
}
|
||||
|
||||
public WebFrame(String content) throws HeadlessException {
|
||||
addWindowListener(new WindowListener() {
|
||||
@Override
|
||||
public void windowOpened(WindowEvent e) {
|
||||
}
|
||||
|
||||
addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
SwingUtils.exitIfNoWindow(WebFrame.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowClosed(WindowEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowIconified(WindowEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowDeiconified(WindowEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowActivated(WindowEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowDeactivated(WindowEvent e) {
|
||||
}
|
||||
});
|
||||
|
||||
add(new WebPage(content));
|
||||
|
||||
@@ -27,6 +27,11 @@ launch.not_finished_decompressing_natives=未能解压游戏本地库,还要
|
||||
launch.wrong_javadir=错误的Java路径,将自动重置为默认Java路径。
|
||||
launch.exited_abnormally=游戏非正常退出,请查看日志文件,或联系他人寻求帮助。
|
||||
|
||||
launch.state.logging_in=登录中
|
||||
launch.state.generating_launching_codes=正在生成启动代码
|
||||
launch.state.downloading_libraries=正在下载必要文件
|
||||
launch.state.decompressing_natives=正在释放本地文件
|
||||
|
||||
install.no_version=未找到要安装的对应MC版本
|
||||
install.no_version_if_intall=未找到要安装的对应MC版本,是否自动安装需要的MC版本?
|
||||
install.not_refreshed=未刷新列表
|
||||
|
||||
@@ -27,6 +27,11 @@ launch.not_finished_decompressing_natives=\u672a\u80fd\u89e3\u538b\u6e38\u620f\u
|
||||
launch.wrong_javadir=\u9519\u8bef\u7684Java\u8def\u5f84\uff0c\u5c06\u81ea\u52a8\u91cd\u7f6e\u4e3a\u9ed8\u8ba4Java\u8def\u5f84\u3002
|
||||
launch.exited_abnormally=\u6e38\u620f\u975e\u6b63\u5e38\u9000\u51fa\uff0c\u8bf7\u67e5\u770b\u65e5\u5fd7\u6587\u4ef6\uff0c\u6216\u8054\u7cfb\u4ed6\u4eba\u5bfb\u6c42\u5e2e\u52a9\u3002
|
||||
|
||||
launch.state.logging_in=\u767b\u5f55\u4e2d
|
||||
launch.state.generating_launching_codes=\u6b63\u5728\u751f\u6210\u542f\u52a8\u4ee3\u7801
|
||||
launch.state.downloading_libraries=\u6b63\u5728\u4e0b\u8f7d\u5fc5\u8981\u6587\u4ef6
|
||||
launch.state.decompressing_natives=\u6b63\u5728\u91ca\u653e\u672c\u5730\u6587\u4ef6
|
||||
|
||||
install.no_version=\u672a\u627e\u5230\u8981\u5b89\u88c5\u7684\u5bf9\u5e94MC\u7248\u672c
|
||||
install.no_version_if_intall=\u672a\u627e\u5230\u8981\u5b89\u88c5\u7684\u5bf9\u5e94MC\u7248\u672c\uff0c\u662f\u5426\u81ea\u52a8\u5b89\u88c5\u9700\u8981\u7684MC\u7248\u672c\uff1f
|
||||
install.not_refreshed=\u672a\u5237\u65b0\u5217\u8868
|
||||
|
||||
@@ -27,6 +27,11 @@ launch.not_finished_decompressing_natives=Did not finish decompressing native li
|
||||
launch.wrong_javadir=Wrong Java Dir, will reset to default Java dir.
|
||||
launch.exited_abnormally=Game exited abnormally, please visit the log, or ask someone for help.
|
||||
|
||||
launch.state.logging_in=Logging In
|
||||
launch.state.generating_launching_codes=Generating Launching Codes
|
||||
launch.state.downloading_libraries=Downloading dependencies
|
||||
launch.state.decompressing_natives=Decompressing natives
|
||||
|
||||
install.no_version=The version is not found.
|
||||
install.no_version_if_intall=The needed version is not found, should install the version automatically?
|
||||
install.not_refreshed=The installer list is not refreshed.
|
||||
|
||||
@@ -27,6 +27,11 @@ launch.not_finished_decompressing_natives=Did not finish decompressing native li
|
||||
launch.wrong_javadir=Wrong Java Dir, will reset to default Java dir.
|
||||
launch.exited_abnormally=Game exited abnormally, please visit the log, or ask someone for help.
|
||||
|
||||
launch.state.logging_in=Logging In
|
||||
launch.state.generating_launching_codes=Generating Launching Codes
|
||||
launch.state.downloading_libraries=Downloading dependencies
|
||||
launch.state.decompressing_natives=Decompressing natives
|
||||
|
||||
install.no_version=The version is not found.
|
||||
install.no_version_if_intall=The needed version is not found, should install the version automatically?
|
||||
install.not_refreshed=The installer list is not refreshed.
|
||||
|
||||
@@ -27,6 +27,11 @@ launch.not_finished_decompressing_natives=未能解壓遊戲本地庫,還要
|
||||
launch.wrong_javadir=錯誤的Java路徑,將自動重置為默認Java路徑。
|
||||
launch.exited_abnormally=遊戲非正常退出,請查看日誌資料,或聯繫他人尋求幫助。
|
||||
|
||||
launch.state.logging in=登錄中
|
||||
launch.state.generating launching codes=正在生成啟動代碼
|
||||
launch.state.downloading_libraries=正在下載必要文件
|
||||
launch.state.decompressing_natives=正在釋放本地文件
|
||||
|
||||
install.no_version=未找到要安裝的對應MC版本
|
||||
install.no_version_if_intall=未找到要安裝的對應MC版本,是否自动安装需要的MC版本?
|
||||
install.not_refreshed=未刷新列表
|
||||
|
||||
@@ -27,6 +27,11 @@ launch.not_finished_decompressing_natives=\u672a\u80fd\u89e3\u58d3\u904a\u6232\u
|
||||
launch.wrong_javadir=\u932f\u8aa4\u7684Java\u8def\u5f91\uff0c\u5c07\u81ea\u52d5\u91cd\u7f6e\u70ba\u9ed8\u8a8dJava\u8def\u5f91\u3002
|
||||
launch.exited_abnormally=\u904a\u6232\u975e\u6b63\u5e38\u9000\u51fa\uff0c\u8acb\u67e5\u770b\u65e5\u8a8c\u8cc7\u6599\uff0c\u6216\u806f\u7e6b\u4ed6\u4eba\u5c0b\u6c42\u5e6b\u52a9\u3002
|
||||
|
||||
launch.state.logging in=\u767b\u9304\u4e2d
|
||||
launch.state.generating launching codes=\u6b63\u5728\u751f\u6210\u555f\u52d5\u4ee3\u78bc
|
||||
launch.state.downloading_libraries=\u6b63\u5728\u4e0b\u8f09\u5fc5\u8981\u6587\u4ef6
|
||||
launch.state.decompressing_natives=\u6b63\u5728\u91cb\u653e\u672c\u5730\u6587\u4ef6
|
||||
|
||||
install.no_version=\u672a\u627e\u5230\u8981\u5b89\u88dd\u7684\u5c0d\u61c9MC\u7248\u672c
|
||||
install.no_version_if_intall=\u672a\u627e\u5230\u8981\u5b89\u88dd\u7684\u5c0d\u61c9MC\u7248\u672c\uff0c\u662f\u5426\u81ea\u52a8\u5b89\u88c5\u9700\u8981\u7684MC\u7248\u672c\uff1f
|
||||
install.not_refreshed=\u672a\u5237\u65b0\u5217\u8868
|
||||
|
||||
Reference in New Issue
Block a user