for darkyoooooo's advice

This commit is contained in:
huangyuhui 2016-02-09 22:28:36 +08:00
parent cb5391ed28
commit 21dcb477dc
14 changed files with 334 additions and 266 deletions

View File

@ -118,7 +118,7 @@ public abstract class IAssetsHandler {
IOUtils.closeQuietly(fis); IOUtils.closeQuietly(fis);
if (contents.get(i).geteTag().equals(sha)) { if (contents.get(i).geteTag().equals(sha)) {
hasDownloaded++; hasDownloaded++;
HMCLog.log("File " + assetsLocalNames.get(i) + " has downloaded successfully, skipped downloading."); HMCLog.log("File " + assetsLocalNames.get(i) + " has been downloaded successfully, skipped download.");
if (ppl != null) if (ppl != null)
ppl.setProgress(this, hasDownloaded, max); ppl.setProgress(this, hasDownloaded, max);
continue; continue;

View File

@ -20,11 +20,15 @@ package org.jackhuang.hellominecraft.launcher.core.asset;
import com.google.gson.JsonSyntaxException; import com.google.gson.JsonSyntaxException;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Map;
import org.jackhuang.hellominecraft.util.C; import org.jackhuang.hellominecraft.util.C;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftAssetService; import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftAssetService;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftProvider;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService; import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
import org.jackhuang.hellominecraft.launcher.core.version.AssetIndexDownloadInfo; import org.jackhuang.hellominecraft.launcher.core.version.AssetIndexDownloadInfo;
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion; import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
import org.jackhuang.hellominecraft.util.MessageBox;
import org.jackhuang.hellominecraft.util.func.Function;
import org.jackhuang.hellominecraft.util.logging.HMCLog; import org.jackhuang.hellominecraft.util.logging.HMCLog;
import org.jackhuang.hellominecraft.util.tasks.Task; import org.jackhuang.hellominecraft.util.tasks.Task;
import org.jackhuang.hellominecraft.util.tasks.TaskWindow; import org.jackhuang.hellominecraft.util.tasks.TaskWindow;
@ -116,4 +120,78 @@ public class MinecraftAssetService extends IMinecraftAssetService {
throw new IOException("Assets file format malformed.", e); throw new IOException("Assets file format malformed.", e);
} }
} }
private boolean checkAssetsExistance(AssetIndexDownloadInfo assetIndex) {
File assetsDir = getAssets();
File indexDir = new File(assetsDir, "indexes");
File objectDir = new File(assetsDir, "objects");
File indexFile = new File(indexDir, assetIndex.getId() + ".json");
if (!assetsDir.exists() && !indexFile.isFile())
return false;
try {
AssetsIndex index = (AssetsIndex) C.GSON.fromJson(FileUtils.readFileToString(indexFile, "UTF-8"), AssetsIndex.class);
if (index == null)
return false;
for (Map.Entry entry : index.getFileMap().entrySet())
if (!new File(new File(objectDir, ((AssetsObject) entry.getValue()).getHash().substring(0, 2)), ((AssetsObject) entry.getValue()).getHash()).exists())
return false;
return true;
} catch (IOException | JsonSyntaxException e) {
return false;
}
}
private File reconstructAssets(AssetIndexDownloadInfo assetIndex) {
File assetsDir = getAssets();
File indexDir = new File(assetsDir, "indexes");
File objectDir = new File(assetsDir, "objects");
String assetVersion = assetIndex.getId();
File indexFile = new File(indexDir, assetVersion + ".json");
File virtualRoot = new File(new File(assetsDir, "virtual"), assetVersion);
if (!indexFile.isFile()) {
HMCLog.warn("No assets index file " + virtualRoot + "; can't reconstruct assets");
return assetsDir;
}
try {
AssetsIndex index = (AssetsIndex) C.GSON.fromJson(FileUtils.readFileToString(indexFile, "UTF-8"), AssetsIndex.class);
if (index == null)
return assetsDir;
if (index.isVirtual()) {
int cnt = 0;
HMCLog.log("Reconstructing virtual assets folder at " + virtualRoot);
int tot = index.getFileMap().entrySet().size();
for (Map.Entry entry : index.getFileMap().entrySet()) {
File target = new File(virtualRoot, (String) entry.getKey());
File original = new File(new File(objectDir, ((AssetsObject) entry.getValue()).getHash().substring(0, 2)), ((AssetsObject) entry.getValue()).getHash());
if (original.exists()) {
cnt++;
if (!target.isFile())
FileUtils.copyFile(original, target, false);
}
}
// If the scale new format existent file is lower then 0.1, use the old format.
if (cnt * 10 < tot)
return assetsDir;
}
} catch (IOException | JsonSyntaxException e) {
HMCLog.warn("Failed to create virutal assets.", e);
}
return virtualRoot;
}
public final Function<MinecraftVersion, String> ASSET_PROVIDER_IMPL = t -> {
if (!checkAssetsExistance(t.getAssetsIndex()))
if (MessageBox.Show(C.i18n("assets.no_assets"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) {
IAssetsHandler.ASSETS_HANDLER.getList(t, MinecraftAssetService.this).run();
TaskWindow.factory().append(IAssetsHandler.ASSETS_HANDLER.getDownloadTask(service.getDownloadType().getProvider())).create();
}
return reconstructAssets(t.getAssetsIndex()).getAbsolutePath();
};
} }

View File

@ -36,7 +36,7 @@ public abstract class IAuthenticator {
PluginManager.plugin().onRegisterAuthenticators(LOGINS::add); PluginManager.plugin().onRegisterAuthenticators(LOGINS::add);
} }
protected String clientToken, username; protected String clientToken, username, password;
public IAuthenticator(String clientToken) { public IAuthenticator(String clientToken) {
this.clientToken = clientToken; this.clientToken = clientToken;
@ -106,4 +106,12 @@ public abstract class IAuthenticator {
public void setUserName(String s) { public void setUserName(String s) {
username = s; username = s;
} }
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
} }

View File

@ -17,18 +17,12 @@
*/ */
package org.jackhuang.hellominecraft.launcher.core.launch; package org.jackhuang.hellominecraft.launcher.core.launch;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftLoader;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.jackhuang.hellominecraft.util.C; import org.jackhuang.hellominecraft.util.C;
import org.jackhuang.hellominecraft.util.logging.HMCLog; import org.jackhuang.hellominecraft.util.logging.HMCLog;
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;
import org.jackhuang.hellominecraft.util.system.JdkVersion; import org.jackhuang.hellominecraft.util.system.JdkVersion;
import org.jackhuang.hellominecraft.util.MathUtils; import org.jackhuang.hellominecraft.util.MathUtils;
import org.jackhuang.hellominecraft.util.MessageBox; import org.jackhuang.hellominecraft.util.MessageBox;
@ -36,6 +30,12 @@ import org.jackhuang.hellominecraft.util.system.OS;
import org.jackhuang.hellominecraft.util.system.Platform; import org.jackhuang.hellominecraft.util.system.Platform;
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.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;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftLoader;
/** /**
* *

View File

@ -57,7 +57,7 @@ public class DefaultGameLauncher extends GameLauncher {
try { try {
Compressor.unzip(value.decompressFiles[i], value.getDecompressTo(), value.extractRules[i]::allow, false); Compressor.unzip(value.decompressFiles[i], value.getDecompressTo(), value.extractRules[i]::allow, false);
} catch (IOException ex) { } catch (IOException ex) {
HMCLog.err("Unable to decompress library file: " + value.decompressFiles[i] + " to " + value.getDecompressTo(), ex); HMCLog.err("Unable to decompress library: " + value.decompressFiles[i] + " to " + value.getDecompressTo(), ex);
} }
return true; return true;
}); });

View File

@ -17,26 +17,19 @@
*/ */
package org.jackhuang.hellominecraft.launcher.core.launch; package org.jackhuang.hellominecraft.launcher.core.launch;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
import com.google.gson.JsonSyntaxException;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Map; import org.jackhuang.hellominecraft.util.StrUtils;
import org.jackhuang.hellominecraft.util.C; import org.jackhuang.hellominecraft.util.func.Function;
import org.jackhuang.hellominecraft.util.logging.HMCLog; import org.jackhuang.hellominecraft.util.logging.HMCLog;
import org.jackhuang.hellominecraft.util.system.IOUtils;
import org.jackhuang.hellominecraft.util.system.OS;
import org.jackhuang.hellominecraft.launcher.core.GameException; import org.jackhuang.hellominecraft.launcher.core.GameException;
import org.jackhuang.hellominecraft.launcher.core.auth.UserProfileProvider; import org.jackhuang.hellominecraft.launcher.core.auth.UserProfileProvider;
import org.jackhuang.hellominecraft.util.system.IOUtils;
import org.jackhuang.hellominecraft.launcher.core.asset.AssetsIndex;
import org.jackhuang.hellominecraft.launcher.core.asset.AssetsObject;
import org.jackhuang.hellominecraft.launcher.core.asset.IAssetsHandler;
import org.jackhuang.hellominecraft.util.system.OS;
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftLibrary; import org.jackhuang.hellominecraft.launcher.core.version.MinecraftLibrary;
import org.jackhuang.hellominecraft.util.tasks.TaskWindow; import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
import org.jackhuang.hellominecraft.util.system.FileUtils; import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
import org.jackhuang.hellominecraft.util.MessageBox;
import org.jackhuang.hellominecraft.util.StrUtils;
/** /**
* *
@ -68,13 +61,7 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
String[] splitted = StrUtils.tokenize(version.minecraftArguments); String[] splitted = StrUtils.tokenize(version.minecraftArguments);
if (!checkAssetsExist()) String game_assets = assetProvider.apply(version);
if (MessageBox.Show(C.i18n("assets.no_assets"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) {
IAssetsHandler.ASSETS_HANDLER.getList(version, service.asset()).run();
TaskWindow.factory().append(IAssetsHandler.ASSETS_HANDLER.getDownloadTask(service.getDownloadType().getProvider())).create();
}
String game_assets = reconstructAssets().getAbsolutePath();
for (String t : splitted) { for (String t : splitted) {
t = t.replace("${auth_player_name}", lr.getUserName()); t = t.replace("${auth_player_name}", lr.getUserName());
@ -113,68 +100,16 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
} }
} }
private boolean checkAssetsExist() { private final Function<MinecraftVersion, String> DEFAULT_ASSET_PROVIDER = t -> {
File assetsDir = new File(service.baseDirectory(), "assets"); return new File(service.baseDirectory(), "assets").getAbsolutePath();
File indexDir = new File(assetsDir, "indexes"); };
File objectDir = new File(assetsDir, "objects");
File indexFile = new File(indexDir, version.getAssetsIndex().getId() + ".json");
if (!assetsDir.exists() && !indexFile.isFile()) private Function<MinecraftVersion, String> assetProvider = DEFAULT_ASSET_PROVIDER;
return false;
try { public void setAssetProvider(Function<MinecraftVersion, String> assetProvider) {
AssetsIndex index = (AssetsIndex) C.GSON.fromJson(FileUtils.readFileToString(indexFile, "UTF-8"), AssetsIndex.class); if (assetProvider == null)
this.assetProvider = DEFAULT_ASSET_PROVIDER;
if (index == null) else
return false; this.assetProvider = assetProvider;
for (Map.Entry entry : index.getFileMap().entrySet())
if (!new File(new File(objectDir, ((AssetsObject) entry.getValue()).getHash().substring(0, 2)), ((AssetsObject) entry.getValue()).getHash()).exists())
return false;
return true;
} catch (IOException | JsonSyntaxException e) {
return false;
}
}
private File reconstructAssets() {
File assetsDir = new File(service.baseDirectory(), "assets");
File indexDir = new File(assetsDir, "indexes");
File objectDir = new File(assetsDir, "objects");
String assetVersion = version.getAssetsIndex().getId();
File indexFile = new File(indexDir, assetVersion + ".json");
File virtualRoot = new File(new File(assetsDir, "virtual"), assetVersion);
if (!indexFile.isFile()) {
HMCLog.warn("No assets index file " + virtualRoot + "; can't reconstruct assets");
return assetsDir;
}
try {
AssetsIndex index = (AssetsIndex) C.GSON.fromJson(FileUtils.readFileToString(indexFile, "UTF-8"), AssetsIndex.class);
if (index == null)
return assetsDir;
if (index.isVirtual()) {
int cnt = 0;
HMCLog.log("Reconstructing virtual assets folder at " + virtualRoot);
int tot = index.getFileMap().entrySet().size();
for (Map.Entry entry : index.getFileMap().entrySet()) {
File target = new File(virtualRoot, (String) entry.getKey());
File original = new File(new File(objectDir, ((AssetsObject) entry.getValue()).getHash().substring(0, 2)), ((AssetsObject) entry.getValue()).getHash());
if (original.exists()) {
cnt++;
if (!target.isFile())
FileUtils.copyFile(original, target, false);
}
}
// If the scale new format existent file is lower then 0.1, use the old format.
if (cnt * 10 < tot)
return assetsDir;
}
} catch (IOException | JsonSyntaxException e) {
HMCLog.warn("Failed to create virutal assets.", e);
}
return virtualRoot;
} }
} }

View File

@ -147,7 +147,9 @@ public class DefaultMinecraftService extends IMinecraftService {
@Override @Override
public IMinecraftLoader launch(LaunchOptions options, UserProfileProvider p) throws GameException { public IMinecraftLoader launch(LaunchOptions options, UserProfileProvider p) throws GameException {
return new MinecraftLoader(options, this, p); MinecraftLoader l = new MinecraftLoader(options, this, p);
l.setAssetProvider(mas.ASSET_PROVIDER_IMPL);
return l;
} }
public Profile getProfile() { public Profile getProfile() {

View File

@ -84,6 +84,11 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
setBackground(Color.white); setBackground(Color.white);
setOpaque(true); setOpaque(true);
MainFrame.INSTANCE.actions.put("showGameDownloads", () -> {
MainFrame.INSTANCE.selectTab("game");
showGameDownloads();
});
for (int i = 0; i < InstallerType.values().length; i++) for (int i = 0; i < InstallerType.values().length; i++)
installerPanels[i] = new InstallerPanel(this, InstallerType.values()[i]); installerPanels[i] = new InstallerPanel(this, InstallerType.values()[i]);
pnlGameDownloads = new GameDownloadPanel(this); pnlGameDownloads = new GameDownloadPanel(this);
@ -1122,7 +1127,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
private void btnTestGameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTestGameActionPerformed private void btnTestGameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTestGameActionPerformed
LogWindow.INSTANCE.setVisible(true); LogWindow.INSTANCE.setVisible(true);
MainFrame.INSTANCE.mainPanel.runGame(); MainFrame.INSTANCE.daemon.runGame(getProfile());
}//GEN-LAST:event_btnTestGameActionPerformed }//GEN-LAST:event_btnTestGameActionPerformed
private void btnShowLogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnShowLogActionPerformed private void btnShowLogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnShowLogActionPerformed
@ -1130,7 +1135,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
}//GEN-LAST:event_btnShowLogActionPerformed }//GEN-LAST:event_btnShowLogActionPerformed
private void btnMakeLaunchScriptActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMakeLaunchScriptActionPerformed private void btnMakeLaunchScriptActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMakeLaunchScriptActionPerformed
MainFrame.INSTANCE.mainPanel.makeLaunchScript(); MainFrame.INSTANCE.daemon.makeLaunchScript(getProfile());
}//GEN-LAST:event_btnMakeLaunchScriptActionPerformed }//GEN-LAST:event_btnMakeLaunchScriptActionPerformed
private void btnIncludeMinecraftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnIncludeMinecraftActionPerformed private void btnIncludeMinecraftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnIncludeMinecraftActionPerformed

View File

@ -0,0 +1,111 @@
/*
* 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.ui;
import java.io.IOException;
import java.util.List;
import javax.swing.JOptionPane;
import org.jackhuang.hellominecraft.launcher.core.LauncherVisibility;
import org.jackhuang.hellominecraft.launcher.core.launch.GameLauncher;
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.logging.HMCLog;
import org.jackhuang.hellominecraft.util.system.JavaProcessMonitor;
import org.jackhuang.hellominecraft.util.ui.LogWindow;
/**
*
* @author huangyuhui
*/
public class LaunchingUIDaemon {
Runnable customizedSuccessEvent = null;
void runGame(Profile profile) {
MainFrame.INSTANCE.showMessage(C.i18n("ui.message.launching"));
profile.launcher().genLaunchCode(value -> {
value.successEvent.register(LAUNCH_FINISHER);
value.successEvent.register(customizedSuccessEvent);
}, MainFrame.INSTANCE::failed, Settings.getInstance().getAuthenticator().getPassword());
}
void makeLaunchScript(Profile profile) {
MainFrame.INSTANCE.showMessage(C.i18n("ui.message.launching"));
profile.launcher().genLaunchCode(value -> {
value.successEvent.register(LAUNCH_SCRIPT_FINISHER);
value.successEvent.register(customizedSuccessEvent);
}, MainFrame.INSTANCE::failed, Settings.getInstance().getAuthenticator().getPassword());
}
private static final Event<List<String>> LAUNCH_FINISHER = (sender, str) -> {
final GameLauncher obj = (GameLauncher) sender;
obj.launchEvent.register(p -> {
if ((LauncherVisibility) obj.getTag() == LauncherVisibility.CLOSE && !LogWindow.INSTANCE.isVisible()) {
HMCLog.log("Without the option of keeping the launcher visible, this application will exit and will NOT catch game logs, but you can turn on \"Debug Mode\".");
System.exit(0);
} else if ((LauncherVisibility) obj.getTag() == LauncherVisibility.KEEP)
MainFrame.INSTANCE.closeMessage();
else {
if (LogWindow.INSTANCE.isVisible())
LogWindow.INSTANCE.setExit(() -> true);
MainFrame.INSTANCE.dispose();
}
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);
});
jpm.jvmLaunchFailedEvent.register(t -> {
HMCLog.err("Cannot create jvm, exit code: " + t);
MessageBox.Show(C.i18n("launch.cannot_create_jvm") + ", exit code: " + t);
});
jpm.stoppedEvent.register(() -> {
if ((LauncherVisibility) obj.getTag() != LauncherVisibility.KEEP && !LogWindow.INSTANCE.isVisible()) {
HMCLog.log("Without the option of keeping the launcher visible, this application will exit and will NOT catch game logs, but you can turn on \"Debug Mode\".");
System.exit(0);
}
});
jpm.start();
});
try {
obj.launch(str);
} catch (IOException e) {
MainFrame.INSTANCE.failed(C.i18n("launch.failed_creating_process") + "\n" + e.getMessage());
HMCLog.err("Failed to launch when creating a new process.", e);
}
return true;
};
private static final Event<List<String>> LAUNCH_SCRIPT_FINISHER = (sender, str) -> {
boolean flag = false;
try {
String s = JOptionPane.showInputDialog(C.i18n("mainwindow.enter_script_name"));
if (s != null)
MessageBox.Show(C.i18n("mainwindow.make_launch_succeed") + " " + ((GameLauncher) sender).makeLauncher(s, str).getAbsolutePath());
flag = true;
} catch (IOException ex) {
MessageBox.Show(C.i18n("mainwindow.make_launch_script_failed"));
HMCLog.err("Failed to create script file.", ex);
}
MainFrame.INSTANCE.closeMessage();
return flag;
};
}

View File

@ -32,6 +32,9 @@ import java.awt.event.MouseListener;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.awt.event.WindowListener; import java.awt.event.WindowListener;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.Box; import javax.swing.Box;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
@ -47,6 +50,7 @@ import org.jackhuang.hellominecraft.launcher.setting.Settings;
import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator; import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator;
import org.jackhuang.hellominecraft.lookandfeel.GraphicsUtils; import org.jackhuang.hellominecraft.lookandfeel.GraphicsUtils;
import org.jackhuang.hellominecraft.lookandfeel.Theme; import org.jackhuang.hellominecraft.lookandfeel.Theme;
import org.jackhuang.hellominecraft.util.MessageBox;
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.ui.DropShadowBorder; import org.jackhuang.hellominecraft.util.ui.DropShadowBorder;
@ -61,17 +65,10 @@ public final class MainFrame extends DraggableFrame {
public static final MainFrame INSTANCE = new MainFrame(); public static final MainFrame INSTANCE = new MainFrame();
HeaderTab mainTab, gameTab, launcherTab;
TintablePanel centralPanel; TintablePanel centralPanel;
JPanel header; JPanel header, infoSwap, realPanel;
MainPagePanel mainPanel;
GameSettingsPanel gamePanel;
LauncherSettingsPanel launcherPanel;
CardLayout infoLayout; CardLayout infoLayout;
JPanel infoSwap;
JPanel mainPanelWrapper, launcherPanelWrapper, gamePanelWrapper;
JLabel backgroundLabel, windowTitle; JLabel backgroundLabel, windowTitle;
JPanel realPanel;
DropShadowBorder border; DropShadowBorder border;
boolean enableShadow; boolean enableShadow;
String defaultTitle; String defaultTitle;
@ -95,7 +92,6 @@ public final class MainFrame extends DraggableFrame {
setDefaultCloseOperation(3); setDefaultCloseOperation(3);
setTitle(Main.makeTitle()); setTitle(Main.makeTitle());
initComponents(); initComponents();
selectTab("main");
loadBackground(); loadBackground();
setLocationRelativeTo(null); setLocationRelativeTo(null);
@ -150,6 +146,8 @@ public final class MainFrame extends DraggableFrame {
((JPanel) getContentPane()).setOpaque(true); ((JPanel) getContentPane()).setOpaque(true);
Settings.getInstance().themeChangedEvent.register(this::reloadColor); Settings.getInstance().themeChangedEvent.register(this::reloadColor);
SwingUtilities.invokeLater(() -> selectTab("main"));
} }
private void initComponents() { private void initComponents() {
@ -176,31 +174,9 @@ public final class MainFrame extends DraggableFrame {
header.add(Box.createRigidArea(new Dimension(8, 0))); header.add(Box.createRigidArea(new Dimension(8, 0)));
ActionListener tabListener = e -> MainFrame.this.selectTab(e.getActionCommand()); initializeTab(MainPagePanel.class, "main");
initializeTab(GameSettingsPanel.class, "game");
this.mainTab = new HeaderTab(C.i18n("launcher.title.main")); initializeTab(LauncherSettingsPanel.class, "launcher");
this.mainTab.setForeground(BasicColors.COLOR_WHITE_TEXT);
this.mainTab.setBackground(borderColorDarker);
this.mainTab.setActionCommand("main");
this.mainTab.addActionListener(tabListener);
header.add(this.mainTab);
this.gameTab = new HeaderTab(C.i18n("launcher.title.game"));
this.gameTab.setForeground(BasicColors.COLOR_WHITE_TEXT);
this.gameTab.setBackground(borderColorDarker);
this.gameTab.setIsActive(true);
this.gameTab.setHorizontalTextPosition(10);
this.gameTab.addActionListener(tabListener);
this.gameTab.setActionCommand("game");
header.add(this.gameTab);
this.launcherTab = new HeaderTab(C.i18n("launcher.title.launcher"));
this.launcherTab.setForeground(BasicColors.COLOR_WHITE_TEXT);
this.launcherTab.setBackground(borderColorDarker);
this.launcherTab.setLayout(null);
this.launcherTab.addActionListener(tabListener);
this.launcherTab.setActionCommand("launcher");
header.add(this.launcherTab);
header.add(Box.createHorizontalGlue()); header.add(Box.createHorizontalGlue());
@ -253,15 +229,13 @@ public final class MainFrame extends DraggableFrame {
this.infoSwap.setLayout(infoLayout); this.infoSwap.setLayout(infoLayout);
this.infoSwap.setOpaque(false); this.infoSwap.setOpaque(false);
mainPanelWrapper = new JPanel(); tabWrapper = new JPanel[tabHeader.size()];
mainPanelWrapper.setLayout(new GridLayout()); tabContent = new AnimatedPanel[tabHeader.size()];
this.infoSwap.add(mainPanelWrapper, "main"); for (int i = 0; i < tabHeader.size(); i++) {
gamePanelWrapper = new JPanel(); tabWrapper[i] = new JPanel();
gamePanelWrapper.setLayout(new GridLayout()); tabWrapper[i].setLayout(new GridLayout());
this.infoSwap.add(gamePanelWrapper, "game"); infoSwap.add(tabWrapper[i], tabHeader.get(i).getActionCommand());
launcherPanelWrapper = new JPanel(); }
launcherPanelWrapper.setLayout(new GridLayout());
this.infoSwap.add(launcherPanelWrapper, "launcher");
truePanel.add(this.infoSwap, "Center"); truePanel.add(this.infoSwap, "Center");
centralPanel.setLayout(null); centralPanel.setLayout(null);
@ -274,40 +248,48 @@ public final class MainFrame extends DraggableFrame {
add(realPanel); add(realPanel);
} }
public void selectTab(String tabName) { private final ActionListener tabListener = e -> MainFrame.this.selectTab(e.getActionCommand());
boolean a = mainTab.isActive(), b = gameTab.isActive(), c = launcherTab.isActive();
this.mainTab.setIsActive(false);
this.gameTab.setIsActive(false);
this.launcherTab.setIsActive(false);
if (tabName.equalsIgnoreCase("main")) { private void initializeTab(Class<? extends AnimatedPanel> c, String cmd) {
if (mainPanel == null) { HeaderTab tab = new HeaderTab(C.i18n("launcher.title." + cmd));
mainPanel = new MainPagePanel(); tab.setActionCommand(cmd);
mainPanelWrapper.add(mainPanel); tab.setForeground(BasicColors.COLOR_WHITE_TEXT);
} tab.setBackground(borderColorDarker);
this.mainTab.setIsActive(true); tab.setLayout(null);
this.mainPanel.onSelected(); tab.addActionListener(tabListener);
if (!a) header.add(tab);
mainPanel.animate(); tabHeader.add(tab);
} else if (tabName.equalsIgnoreCase("game")) { tabClasses.add(c);
if (gamePanel == null) { }
gamePanel = new GameSettingsPanel();
gamePanelWrapper.add(gamePanel); private List<HeaderTab> tabHeader = new ArrayList<>();
} private List<Class<? extends AnimatedPanel>> tabClasses = new ArrayList<>();
this.gameTab.setIsActive(true); private JPanel tabWrapper[];
this.gamePanel.onSelected(); private AnimatedPanel tabContent[];
if (!b)
gamePanel.animate(); public void selectTab(String tabName) {
} else if (tabName.equalsIgnoreCase("launcher")) { boolean[] activation = new boolean[tabHeader.size()];
if (launcherPanel == null) { for (int i = 0; i < tabHeader.size(); i++) {
launcherPanel = new LauncherSettingsPanel(); activation[i] = tabHeader.get(i).isActive();
launcherPanelWrapper.add(launcherPanel); tabHeader.get(i).setIsActive(false);
}
this.launcherTab.setIsActive(true);
if (!c)
launcherPanel.animate();
} }
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();
} catch (Exception mustnothappen) {
throw new InternalError(mustnothappen);
}
tabWrapper[i].add(tabContent[i]);
}
tabHeader.get(i).setIsActive(true);
tabContent[i].onSelected();
if (!activation[i])
tabContent[i].animate();
}
this.infoLayout.show(this.infoSwap, tabName); this.infoLayout.show(this.infoSwap, tabName);
} }
@ -322,7 +304,7 @@ public final class MainFrame extends DraggableFrame {
ImageIcon background; ImageIcon background;
public void loadBackground() { public void loadBackground() {
background = Utils.searchBackgroundImage(Main.getIcon("background.jpg"), Settings.getInstance().getBgpath(), 800, 480); background = Utils.searchBackgroundImage(Main.getIcon(Settings.getInstance().getTheme().settings.get("Customized.MainFrame.background_image")), Settings.getInstance().getBgpath(), 800, 480);
if (background != null) if (background != null)
if (backgroundLabel == null) { if (backgroundLabel == null) {
backgroundLabel = new JLabel(background); backgroundLabel = new JLabel(background);
@ -331,7 +313,7 @@ public final class MainFrame extends DraggableFrame {
} else } else
backgroundLabel.setIcon(background); backgroundLabel.setIcon(background);
else else
HMCLog.warn("No Background Image, the background will be empty!"); HMCLog.warn("No background image here! The background will be empty!");
} }
public JPanel getTitleBar() { public JPanel getTitleBar() {
@ -354,9 +336,8 @@ public final class MainFrame extends DraggableFrame {
borderColor = BasicColors.COLOR_RED; borderColor = BasicColors.COLOR_RED;
borderColorDarker = BasicColors.COLOR_RED_DARKER; borderColorDarker = BasicColors.COLOR_RED_DARKER;
header.setBackground(borderColor); header.setBackground(borderColor);
mainTab.setBackground(borderColorDarker); for (HeaderTab tab : tabHeader)
gameTab.setBackground(borderColorDarker); tab.setBackground(borderColorDarker);
launcherTab.setBackground(borderColorDarker);
if (border != null) if (border != null)
border.setColor(borderColor); border.setColor(borderColor);
repaint(); repaint();
@ -386,9 +367,8 @@ public final class MainFrame extends DraggableFrame {
if (border != null) if (border != null)
border.setColor(borderColor); border.setColor(borderColor);
header.setBackground(borderColor); header.setBackground(borderColor);
mainTab.setBackground(borderColorDarker); for (HeaderTab tab : tabHeader)
gameTab.setBackground(borderColorDarker); tab.setBackground(borderColorDarker);
launcherTab.setBackground(borderColorDarker);
repaint(); repaint();
} }
@ -458,4 +438,18 @@ public final class MainFrame extends DraggableFrame {
} }
} }
public void failed(String s) {
if (s != null)
MessageBox.Show(s);
closeMessage();
}
LaunchingUIDaemon daemon = new LaunchingUIDaemon();
HashMap<String, Runnable> actions = new HashMap<>();
void invokeAction(String name) {
if (actions.containsKey(name))
actions.get(name).run();
}
} }

View File

@ -213,6 +213,7 @@
</Component> </Component>
<Component class="javax.swing.JPasswordField" name="txtPassword"> <Component class="javax.swing.JPasswordField" name="txtPassword">
<Events> <Events>
<EventHandler event="caretUpdate" listener="javax.swing.event.CaretListener" parameters="javax.swing.event.CaretEvent" handler="txtPasswordCaretUpdate"/>
<EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="txtPasswordFocusGained"/> <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="txtPasswordFocusGained"/>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="txtPasswordActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="txtPasswordActionPerformed"/>
<EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="txtPasswordKeyPressed"/> <EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="txtPasswordKeyPressed"/>

View File

@ -22,21 +22,16 @@ import java.awt.Dimension;
import java.awt.Font; import java.awt.Font;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.io.IOException;
import java.util.List;
import javax.swing.JFileChooser; import javax.swing.JFileChooser;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.filechooser.FileNameExtensionFilter;
import org.jackhuang.hellominecraft.util.C; import org.jackhuang.hellominecraft.util.C;
import org.jackhuang.hellominecraft.util.logging.HMCLog;
import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator; import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator;
import org.jackhuang.hellominecraft.launcher.setting.Profile; import org.jackhuang.hellominecraft.launcher.setting.Profile;
import org.jackhuang.hellominecraft.util.MessageBox; import org.jackhuang.hellominecraft.util.MessageBox;
import org.jackhuang.hellominecraft.util.StrUtils; import org.jackhuang.hellominecraft.util.StrUtils;
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion; import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
import org.jackhuang.hellominecraft.launcher.core.launch.GameLauncher;
import org.jackhuang.hellominecraft.launcher.core.LauncherVisibility;
import org.jackhuang.hellominecraft.launcher.setting.Settings; import org.jackhuang.hellominecraft.launcher.setting.Settings;
import org.jackhuang.hellominecraft.launcher.core.mod.ModpackManager; import org.jackhuang.hellominecraft.launcher.core.mod.ModpackManager;
import org.jackhuang.hellominecraft.launcher.ui.modpack.ModpackWizard; import org.jackhuang.hellominecraft.launcher.ui.modpack.ModpackWizard;
@ -44,9 +39,7 @@ import org.jackhuang.hellominecraft.lookandfeel.GraphicsUtils;
import org.jackhuang.hellominecraft.util.Event; import org.jackhuang.hellominecraft.util.Event;
import org.jackhuang.hellominecraft.lookandfeel.comp.ConstomButton; import org.jackhuang.hellominecraft.lookandfeel.comp.ConstomButton;
import org.jackhuang.hellominecraft.util.system.FileUtils; import org.jackhuang.hellominecraft.util.system.FileUtils;
import org.jackhuang.hellominecraft.util.system.JavaProcessMonitor;
import org.jackhuang.hellominecraft.util.tasks.TaskWindow; import org.jackhuang.hellominecraft.util.tasks.TaskWindow;
import org.jackhuang.hellominecraft.util.ui.LogWindow;
import org.jackhuang.hellominecraft.util.ui.wizard.api.WizardDisplayer; import org.jackhuang.hellominecraft.util.ui.wizard.api.WizardDisplayer;
/** /**
@ -73,7 +66,7 @@ public class MainPagePanel extends AnimatedPanel {
btnRun.setText(C.i18n("ui.button.run")); btnRun.setText(C.i18n("ui.button.run"));
btnRun.setFont(newFont); btnRun.setFont(newFont);
btnRun.addActionListener(e -> runGame()); btnRun.addActionListener(e -> MainFrame.INSTANCE.daemon.runGame(getProfile()));
this.add(pnlButtons); this.add(pnlButtons);
pnlButtons.setBounds(0, 0, w, h); pnlButtons.setBounds(0, 0, w, h);
@ -86,6 +79,8 @@ public class MainPagePanel extends AnimatedPanel {
Settings.getInstance().authChangedEvent.register(onAuthChanged); Settings.getInstance().authChangedEvent.register(onAuthChanged);
MainFrame.INSTANCE.daemon.customizedSuccessEvent = this::prepareAuths;
prepareAuths(); prepareAuths();
} }
@ -166,6 +161,11 @@ public class MainPagePanel extends AnimatedPanel {
jLabel9.setText(C.i18n("ui.label.password")); // NOI18N jLabel9.setText(C.i18n("ui.label.password")); // NOI18N
txtPassword.addCaretListener(new javax.swing.event.CaretListener() {
public void caretUpdate(javax.swing.event.CaretEvent evt) {
txtPasswordCaretUpdate(evt);
}
});
txtPassword.addFocusListener(new java.awt.event.FocusAdapter() { txtPassword.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusGained(java.awt.event.FocusEvent evt) { public void focusGained(java.awt.event.FocusEvent evt) {
txtPasswordFocusGained(evt); txtPasswordFocusGained(evt);
@ -332,7 +332,7 @@ public class MainPagePanel extends AnimatedPanel {
}//GEN-LAST:event_txtPasswordFocusGained }//GEN-LAST:event_txtPasswordFocusGained
private void txtPasswordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtPasswordActionPerformed private void txtPasswordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtPasswordActionPerformed
runGame(); MainFrame.INSTANCE.daemon.runGame(getProfile());
}//GEN-LAST:event_txtPasswordActionPerformed }//GEN-LAST:event_txtPasswordActionPerformed
private void btnLogoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLogoutActionPerformed private void btnLogoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLogoutActionPerformed
@ -352,7 +352,7 @@ public class MainPagePanel extends AnimatedPanel {
IAuthenticator l = Settings.getInstance().getAuthenticator(); IAuthenticator l = Settings.getInstance().getAuthenticator();
l.setUserName(txtPlayerName.getText()); l.setUserName(txtPlayerName.getText());
if (!l.hasPassword()) if (!l.hasPassword())
runGame(); MainFrame.INSTANCE.daemon.runGame(getProfile());
else if (!l.isLoggedIn()) else if (!l.isLoggedIn())
txtPassword.requestFocus(); txtPassword.requestFocus();
} }
@ -360,7 +360,7 @@ public class MainPagePanel extends AnimatedPanel {
private void txtPasswordKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtPasswordKeyPressed private void txtPasswordKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtPasswordKeyPressed
if (evt.getKeyCode() == KeyEvent.VK_ENTER) if (evt.getKeyCode() == KeyEvent.VK_ENTER)
runGame(); MainFrame.INSTANCE.daemon.runGame(getProfile());
}//GEN-LAST:event_txtPasswordKeyPressed }//GEN-LAST:event_txtPasswordKeyPressed
private void btnImportModpackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImportModpackActionPerformed private void btnImportModpackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImportModpackActionPerformed
@ -383,6 +383,10 @@ public class MainPagePanel extends AnimatedPanel {
WizardDisplayer.showWizard(new ModpackWizard(getProfile().service()).createWizard()); WizardDisplayer.showWizard(new ModpackWizard(getProfile().service()).createWizard());
}//GEN-LAST:event_btnExportModpackActionPerformed }//GEN-LAST:event_btnExportModpackActionPerformed
private void txtPasswordCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_txtPasswordCaretUpdate
Settings.getInstance().getAuthenticator().setPassword(txtPassword.getText());
}//GEN-LAST:event_txtPasswordCaretUpdate
// <editor-fold defaultstate="collapsed" desc="Loads"> // <editor-fold defaultstate="collapsed" desc="Loads">
private void prepareAuths() { private void prepareAuths() {
preparingAuth = true; preparingAuth = true;
@ -414,10 +418,8 @@ public class MainPagePanel extends AnimatedPanel {
if (getProfile().service().version().getVersions().isEmpty()) { if (getProfile().service().version().getVersions().isEmpty()) {
if (!showedNoVersion) if (!showedNoVersion)
SwingUtilities.invokeLater(() -> { SwingUtilities.invokeLater(() -> {
if (MessageBox.Show(C.i18n("mainwindow.no_version"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) { if (MessageBox.Show(C.i18n("mainwindow.no_version"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
MainFrame.INSTANCE.selectTab("game"); MainFrame.INSTANCE.invokeAction("showGameDownloads");
MainFrame.INSTANCE.gamePanel.showGameDownloads();
}
showedNoVersion = true; showedNoVersion = true;
}); });
} else { } else {
@ -459,82 +461,6 @@ public class MainPagePanel extends AnimatedPanel {
private static final int DEFAULT_WIDTH = 800, DEFAULT_HEIGHT = 480; private static final int DEFAULT_WIDTH = 800, DEFAULT_HEIGHT = 480;
//</editor-fold> //</editor-fold>
void runGame() {
MainFrame.INSTANCE.showMessage(C.i18n("ui.message.launching"));
getProfile().launcher().genLaunchCode(value -> {
value.successEvent.register(launchFinisher);
value.successEvent.register(this::prepareAuths);
}, this::failed, txtPassword.getText());
}
void makeLaunchScript() {
MainFrame.INSTANCE.showMessage(C.i18n("ui.message.launching"));
getProfile().launcher().genLaunchCode(value -> {
value.successEvent.register(launchScriptFinisher);
value.successEvent.register(this::prepareAuths);
}, this::failed, txtPassword.getText());
}
private void failed(String s) {
if (s != null)
MessageBox.Show(s);
MainFrame.INSTANCE.closeMessage();
}
final Event<List<String>> launchFinisher = (sender, str) -> {
final GameLauncher obj = (GameLauncher) sender;
obj.launchEvent.register(p -> {
if ((LauncherVisibility) obj.getTag() == LauncherVisibility.CLOSE && !LogWindow.INSTANCE.isVisible()) {
HMCLog.log("Without the option of keeping the launcher visible, this application will exit and will NOT catch game logs, but you can turn on \"Debug Mode\".");
System.exit(0);
} else if ((LauncherVisibility) obj.getTag() == LauncherVisibility.KEEP)
MainFrame.INSTANCE.closeMessage();
else {
if (LogWindow.INSTANCE.isVisible())
LogWindow.INSTANCE.setExit(() -> true);
MainFrame.INSTANCE.dispose();
}
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);
});
jpm.jvmLaunchFailedEvent.register(t -> {
HMCLog.err("Cannot create jvm, exit code: " + t);
MessageBox.Show(C.i18n("launch.cannot_create_jvm") + ", exit code: " + t);
});
jpm.stoppedEvent.register(() -> {
if ((LauncherVisibility) obj.getTag() != LauncherVisibility.KEEP && !LogWindow.INSTANCE.isVisible()) {
HMCLog.log("Without the option of keeping the launcher visible, this application will exit and will NOT catch game logs, but you can turn on \"Debug Mode\".");
System.exit(0);
}
});
jpm.start();
});
try {
obj.launch(str);
} catch (IOException e) {
failed(C.i18n("launch.failed_creating_process") + "\n" + e.getMessage());
HMCLog.err("Failed to launch when creating a new process.", e);
}
return true;
};
final Event<List<String>> launchScriptFinisher = (sender, str) -> {
boolean flag = false;
try {
String s = JOptionPane.showInputDialog(C.i18n("mainwindow.enter_script_name"));
if (s != null)
MessageBox.Show(C.i18n("mainwindow.make_launch_succeed") + " " + ((GameLauncher) sender).makeLauncher(s, str).getAbsolutePath());
flag = true;
} catch (IOException ex) {
MessageBox.Show(C.i18n("mainwindow.make_launch_script_failed"));
HMCLog.err("Failed to create script file.", ex);
}
MainFrame.INSTANCE.closeMessage();
return flag;
};
public Profile getProfile() { public Profile getProfile() {
return Settings.getProfile((String) cboProfiles.getSelectedItem()); return Settings.getProfile((String) cboProfiles.getSelectedItem());
} }

View File

@ -48,6 +48,8 @@ import org.jackhuang.hellominecraft.util.ui.wizard.spi.WizardPanelProvider;
public class ModpackWizard extends WizardBranchController { public class ModpackWizard extends WizardBranchController {
static void process(CheckBoxTreeNode node, String basePath, List<String> list) { static void process(CheckBoxTreeNode node, String basePath, List<String> list) {
if (node == null)
return;
if (node.isSelected()) { if (node.isSelected()) {
if (basePath.length() > "minecraft/".length()) if (basePath.length() > "minecraft/".length())
list.add(basePath.substring("minecraft/".length())); list.add(basePath.substring("minecraft/".length()));

View File

@ -32,6 +32,7 @@ public enum Theme {
put("Customized.ComboBox.selected_background", "#A0D8F0"); put("Customized.ComboBox.selected_background", "#A0D8F0");
put("Customized.MainFrame.background", "#106CA3"); put("Customized.MainFrame.background", "#106CA3");
put("Customized.MainFrame.selected_background", "#0C5E91"); put("Customized.MainFrame.selected_background", "#0C5E91");
put("Customized.MainFrame.background_image", "background.jpg");
} }
}), }),
GREEN(C.i18n("color.green"), new HashMap<String, String>() { GREEN(C.i18n("color.green"), new HashMap<String, String>() {
@ -40,6 +41,7 @@ public enum Theme {
put("Customized.ComboBox.selected_background", "#1ABC9C"); put("Customized.ComboBox.selected_background", "#1ABC9C");
put("Customized.MainFrame.background", "#1ABC9C"); put("Customized.MainFrame.background", "#1ABC9C");
put("Customized.MainFrame.selected_background", "#16A085"); put("Customized.MainFrame.selected_background", "#16A085");
put("Customized.MainFrame.background_image", "background.jpg");
} }
}), }),
PURPLE(C.i18n("color.purple"), new HashMap<String, String>() { PURPLE(C.i18n("color.purple"), new HashMap<String, String>() {
@ -48,6 +50,7 @@ public enum Theme {
put("Customized.ComboBox.selected_background", "#9B59B6"); put("Customized.ComboBox.selected_background", "#9B59B6");
put("Customized.MainFrame.background", "#9B59B6"); put("Customized.MainFrame.background", "#9B59B6");
put("Customized.MainFrame.selected_background", "#8E44AD"); put("Customized.MainFrame.selected_background", "#8E44AD");
put("Customized.MainFrame.background_image", "background.jpg");
} }
}), }),
DARKER_BLUE(C.i18n("color.dark_blue"), new HashMap<String, String>() { DARKER_BLUE(C.i18n("color.dark_blue"), new HashMap<String, String>() {
@ -56,6 +59,7 @@ public enum Theme {
put("Customized.ComboBox.selected_background", "#34495E"); put("Customized.ComboBox.selected_background", "#34495E");
put("Customized.MainFrame.background", "#34495E"); put("Customized.MainFrame.background", "#34495E");
put("Customized.MainFrame.selected_background", "#2C3E50"); put("Customized.MainFrame.selected_background", "#2C3E50");
put("Customized.MainFrame.background_image", "background.jpg");
} }
}), }),
ORANGE(C.i18n("color.orange"), new HashMap<String, String>() { ORANGE(C.i18n("color.orange"), new HashMap<String, String>() {
@ -64,6 +68,7 @@ public enum Theme {
put("Customized.ComboBox.selected_background", "#F39C12"); put("Customized.ComboBox.selected_background", "#F39C12");
put("Customized.MainFrame.background", "#E67E22"); put("Customized.MainFrame.background", "#E67E22");
put("Customized.MainFrame.selected_background", "#D35400"); put("Customized.MainFrame.selected_background", "#D35400");
put("Customized.MainFrame.background_image", "background.jpg");
} }
}), }),
RED(C.i18n("color.red"), new HashMap<String, String>() { RED(C.i18n("color.red"), new HashMap<String, String>() {
@ -72,6 +77,7 @@ public enum Theme {
put("Customized.ComboBox.selected_background", "#E74C3C"); put("Customized.ComboBox.selected_background", "#E74C3C");
put("Customized.MainFrame.background", "#E74C3C"); put("Customized.MainFrame.background", "#E74C3C");
put("Customized.MainFrame.selected_background", "#C0392B"); put("Customized.MainFrame.selected_background", "#C0392B");
put("Customized.MainFrame.background_image", "background.jpg");
} }
}); });