Should fixed #46
This commit is contained in:
@@ -31,6 +31,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
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;
|
||||||
@@ -80,7 +81,7 @@ public final class ModpackManager {
|
|||||||
* @return The installing Task, may take long time, please consider
|
* @return The installing Task, may take long time, please consider
|
||||||
* TaskWindow.
|
* TaskWindow.
|
||||||
*/
|
*/
|
||||||
public static Task install(final File input, final IMinecraftService service, final String idFUCK) {
|
public static Task install(JFrame parFrame, final File input, final IMinecraftService service, final String idFUCK) {
|
||||||
return new Task() {
|
return new Task() {
|
||||||
Collection<Task> c = new ArrayList<>();
|
Collection<Task> c = new ArrayList<>();
|
||||||
|
|
||||||
@@ -110,7 +111,7 @@ public final class ModpackManager {
|
|||||||
msgs[0] = C.i18n("modpack.task.install");
|
msgs[0] = C.i18n("modpack.task.install");
|
||||||
msgs[1] = new WebPage(description);
|
msgs[1] = new WebPage(description);
|
||||||
((WebPage) msgs[1]).setPreferredSize(new Dimension(800, 350));
|
((WebPage) msgs[1]).setPreferredSize(new Dimension(800, 350));
|
||||||
int result = JOptionPane.showOptionDialog(null, msgs, (String) msgs[0], JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
|
int result = JOptionPane.showOptionDialog(parFrame, msgs, (String) msgs[0], JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
|
||||||
if (result == JOptionPane.NO_OPTION)
|
if (result == JOptionPane.NO_OPTION)
|
||||||
throw new NoShownTaskException("Operation was canceled by user.");
|
throw new NoShownTaskException("Operation was canceled by user.");
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ 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.core.service.IMinecraftService;
|
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
|
||||||
import org.jackhuang.hellominecraft.launcher.ui.modpack.ModpackWizard;
|
import org.jackhuang.hellominecraft.launcher.ui.modpack.ModpackWizard;
|
||||||
|
import org.jackhuang.hellominecraft.launcher.util.HMCLMinecraftService;
|
||||||
import org.jackhuang.hellominecraft.util.ui.GraphicsUtils;
|
import org.jackhuang.hellominecraft.util.ui.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;
|
||||||
@@ -382,7 +383,7 @@ public class MainPagePanel extends AnimatedPanel {
|
|||||||
if (fc.getSelectedFile() == null)
|
if (fc.getSelectedFile() == null)
|
||||||
return;
|
return;
|
||||||
String suggestedModpackId = JOptionPane.showInputDialog("Please enter your favourite game name", FileUtils.getBaseName(fc.getSelectedFile().getName()));
|
String suggestedModpackId = JOptionPane.showInputDialog("Please enter your favourite game name", FileUtils.getBaseName(fc.getSelectedFile().getName()));
|
||||||
TaskWindow.factory().append(ModpackManager.install(fc.getSelectedFile(), Settings.getLastProfile().service(), suggestedModpackId)).create();
|
TaskWindow.factory().append(ModpackManager.install(MainFrame.INSTANCE, fc.getSelectedFile(), Settings.getLastProfile().service(), suggestedModpackId)).create();
|
||||||
Settings.getLastProfile().service().version().refreshVersions();
|
Settings.getLastProfile().service().version().refreshVersions();
|
||||||
}//GEN-LAST:event_btnImportModpackActionPerformed
|
}//GEN-LAST:event_btnImportModpackActionPerformed
|
||||||
|
|
||||||
@@ -489,7 +490,7 @@ public class MainPagePanel extends AnimatedPanel {
|
|||||||
cboVersions.removeAllItems();
|
cboVersions.removeAllItems();
|
||||||
String selVersion = Settings.getLastProfile().getSelectedVersion();
|
String selVersion = Settings.getLastProfile().getSelectedVersion();
|
||||||
if (Settings.getLastProfile().service().version().getVersions().isEmpty()) {
|
if (Settings.getLastProfile().service().version().getVersions().isEmpty()) {
|
||||||
if (!showedNoVersion) {
|
if (!showedNoVersion && ((HMCLMinecraftService) Settings.getLastProfile().service()).checkedModpack) {
|
||||||
showedNoVersion = true;
|
showedNoVersion = true;
|
||||||
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)
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import com.google.gson.JsonSyntaxException;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.GameException;
|
import org.jackhuang.hellominecraft.launcher.core.GameException;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.install.MinecraftInstallerService;
|
import org.jackhuang.hellominecraft.launcher.core.install.MinecraftInstallerService;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.asset.MinecraftAssetService;
|
import org.jackhuang.hellominecraft.launcher.core.asset.MinecraftAssetService;
|
||||||
@@ -39,6 +40,7 @@ import org.jackhuang.hellominecraft.launcher.core.mod.MinecraftModService;
|
|||||||
import org.jackhuang.hellominecraft.launcher.core.mod.ModpackManager;
|
import org.jackhuang.hellominecraft.launcher.core.mod.ModpackManager;
|
||||||
import org.jackhuang.hellominecraft.launcher.setting.Profile;
|
import org.jackhuang.hellominecraft.launcher.setting.Profile;
|
||||||
import org.jackhuang.hellominecraft.launcher.setting.VersionSetting;
|
import org.jackhuang.hellominecraft.launcher.setting.VersionSetting;
|
||||||
|
import org.jackhuang.hellominecraft.launcher.ui.MainFrame;
|
||||||
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.util.system.FileUtils;
|
import org.jackhuang.hellominecraft.util.system.FileUtils;
|
||||||
@@ -66,18 +68,20 @@ public class HMCLMinecraftService extends IMinecraftService {
|
|||||||
this.mis = new MinecraftInstallerService(this);
|
this.mis = new MinecraftInstallerService(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean checkedModpack = false, checkingModpack = false;
|
||||||
|
|
||||||
private void checkModpack() {
|
private void checkModpack() {
|
||||||
int show = 0;
|
if (!checkingModpack) {
|
||||||
for (StackTraceElement e : Thread.currentThread().getStackTrace())
|
checkingModpack = true;
|
||||||
if ("checkModpack".equals(e.getMethodName()))
|
if (version().getVersionCount() == 0) {
|
||||||
++show;
|
File modpack = new File("modpack.zip");
|
||||||
if (show > 1)
|
if (modpack.exists())
|
||||||
return;
|
SwingUtilities.invokeLater(() -> {
|
||||||
if (version().getVersionCount() == 0) {
|
if (TaskWindow.execute(ModpackManager.install(MainFrame.INSTANCE, modpack, this, null)))
|
||||||
File modpack = new File("modpack.zip");
|
version().refreshVersions();
|
||||||
if (modpack.exists())
|
checkedModpack = true;
|
||||||
if (TaskWindow.execute(ModpackManager.install(modpack, this, null)))
|
});
|
||||||
version().refreshVersions();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -225,9 +225,11 @@ public class TaskWindow extends javax.swing.JDialog
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
SwingUtilities.invokeLater(this::dispose);
|
SwingUtilities.invokeLater(() -> {
|
||||||
suc = true;
|
dispose();
|
||||||
HMCLog.log("Tasks are finished.");
|
suc = true;
|
||||||
|
HMCLog.log("Tasks are finished.");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user