Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public final class StyleSheets {
getFontStyleSheet(),
getThemeStyleSheet(),
getBrightnessStyleSheet(),
"/assets/css/root.css"
"/assets/css/root.css",
"/assets/css/download-task-list.css"
};
stylesheets = FXCollections.observableList(Arrays.asList(array));

Expand Down
19 changes: 11 additions & 8 deletions HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import org.jackhuang.hmcl.ui.construct.*;
import org.jackhuang.hmcl.ui.construct.MessageDialogPane.MessageType;
import org.jackhuang.hmcl.ui.decorator.DecoratorController;
import org.jackhuang.hmcl.ui.download.DifferentDownloadTask2OneTask;
import org.jackhuang.hmcl.ui.download.DownloadPage;
import org.jackhuang.hmcl.ui.download.ModpackInstallWizardProvider;
import org.jackhuang.hmcl.ui.main.LauncherSettingsPage;
Expand Down Expand Up @@ -580,18 +581,20 @@ public static CompletableFuture<List<PromptDialogPane.Builder.Question<?>>> prom
}

public static TaskExecutorDialogPane taskDialog(TaskExecutor executor, String title, TaskCancellationAction onCancel) {
TaskExecutorDialogPane pane = new TaskExecutorDialogPane(onCancel);
pane.setTitle(title);
pane.setExecutor(executor);
dialog(pane);
return pane;
// TaskExecutorDialogPane pane = new TaskExecutorDialogPane(onCancel);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这是在做什么?

// pane.setExecutor(executor);
// dialog(pane);
// pane.setTitle(title);
return null;
}

public static TaskExecutorDialogPane taskDialog(Task<?> task, String title, TaskCancellationAction onCancel) {
TaskExecutor executor = task.executor();
TaskExecutorDialogPane pane = taskDialog(executor, title, onCancel);
executor.start();
return pane;
String name = task.getName();
// TaskExecutorDialogPane pane = taskDialog(executor, title, onCancel);
// TaskExecutorDialogPane pane = new TaskExecutorDialogPane(onCancel);
new DifferentDownloadTask2OneTask().ExecutorTask2OneTask(executor, name);
return null;
}

public static void navigate(Node node) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Hello Minecraft! Launcher
* Copyright (C) 2026 huangyuhui <huanghongxun2008@126.com> and contributors
*
* 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 <https://www.gnu.org/licenses/>.
*/
package org.jackhuang.hmcl.ui.download;

import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.task.TaskExecutor;
import org.jackhuang.hmcl.ui.versions.DownloadTaskList;

public class DifferentDownloadTask2OneTask{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个类和里面的方法都是什么见鬼的命名?为什么还在 System.out.println


private static DownloadTaskList activeDownloadTaskList;

public static void setActiveDownloadTaskList(DownloadTaskList list) {
activeDownloadTaskList = list;
}

public void WizardTask2OneTask(Task<?> task) {
TaskExecutor executor = task.executor();
if (activeDownloadTaskList != null) {
activeDownloadTaskList.addDownloadEntry(executor, task.getName());
System.out.println("gotolist");
}
}

public void ExecutorTask2OneTask(TaskExecutor executor, String name) {
if (activeDownloadTaskList != null) {
activeDownloadTaskList.addDownloadEntry(executor, name);
System.out.println("gotolist");
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Hello Minecraft! Launcher
* Copyright (C) 2026 huangyuhui <huanghongxun2008@126.com> and contributors
*
* 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 <https://www.gnu.org/licenses/>.
*/
package org.jackhuang.hmcl.ui.download;

import javafx.beans.binding.Bindings;
import javafx.beans.binding.StringBinding;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import org.jackhuang.hmcl.task.TaskExecutor;

import static org.jackhuang.hmcl.util.i18n.I18n.i18n;

public class DownloadEntry {
private final short ProgressIsUncertain = -1;

public static final String STATUS_WAITING = "waiting";
public static final String STATUS_RUNNING = "running";
public static final String STATUS_DONE = "done";
public static final String STATUS_FAILED = "failed";

private final StringProperty name = new SimpleStringProperty();
private final StringProperty status = new SimpleStringProperty();
private final DoubleProperty progress = new SimpleDoubleProperty(ProgressIsUncertain);
private final TaskExecutor executor;


public DownloadEntry(TaskExecutor executor, String name) {
this.executor = executor;
this.name.set(name);
this.status.set(STATUS_WAITING);
}


public String getName() { return name.get(); }
public StringProperty nameProperty() { return name; }

public String getStatus() { return status.get(); }
public StringProperty statusProperty() { return status; }

public StringBinding statusI18NBinding() {
return Bindings.createStringBinding(() -> {
String s = status.get();
if (STATUS_DONE.equals(s)) return i18n("download.task.status.done");
if (STATUS_FAILED.equals(s)) return i18n("download.task.status.failed");
if (STATUS_RUNNING.equals(s)) return i18n("download.task.status.running");
if (STATUS_WAITING.equals(s)) return i18n("download.task.status.waiting");
return i18n("download.task.status.null");
}, status);
}

public double getProgress() { return progress.get(); }
public DoubleProperty progressProperty() { return progress; }

public TaskExecutor getExecutor() { return executor; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.jackhuang.hmcl.task.FileDownloadTask;
import org.jackhuang.hmcl.task.Schedulers;
import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.task.TaskExecutor;
import org.jackhuang.hmcl.ui.Controllers;
import org.jackhuang.hmcl.ui.FXUtils;
import org.jackhuang.hmcl.ui.SVG;
Expand All @@ -42,10 +43,7 @@
import org.jackhuang.hmcl.ui.construct.Validator;
import org.jackhuang.hmcl.ui.decorator.DecoratorAnimatedPage;
import org.jackhuang.hmcl.ui.decorator.DecoratorPage;
import org.jackhuang.hmcl.ui.versions.DownloadListPage;
import org.jackhuang.hmcl.ui.versions.HMCLLocalizedDownloadListPage;
import org.jackhuang.hmcl.ui.versions.VersionPage;
import org.jackhuang.hmcl.ui.versions.Versions;
import org.jackhuang.hmcl.ui.versions.*;
import org.jackhuang.hmcl.ui.wizard.Navigation;
import org.jackhuang.hmcl.ui.wizard.WizardController;
import org.jackhuang.hmcl.ui.wizard.WizardProvider;
Expand Down Expand Up @@ -76,8 +74,10 @@ public class DownloadPage extends DecoratorAnimatedPage implements DecoratorPage
private final TabHeader.Tab<DownloadListPage> resourcePackTab = new TabHeader.Tab<>("resourcePackTab");
private final TabHeader.Tab<DownloadListPage> shaderTab = new TabHeader.Tab<>("shaderTab");
private final TabHeader.Tab<DownloadListPage> worldTab = new TabHeader.Tab<>("worldTab");
private final TabHeader.Tab<DownloadListPage> downloadListTab = new TabHeader.Tab<>("downloadListTab");
private final TransitionPane transitionPane = new TransitionPane();
private final DownloadNavigator versionPageNavigator = new DownloadNavigator();
private final DownloadTaskList downloadTaskList;

private WeakListenerHolder listenerHolder;

Expand All @@ -86,6 +86,9 @@ public DownloadPage() {
}

public DownloadPage(String uploadVersion) {
this.downloadTaskList = new DownloadTaskList();
DifferentDownloadTask2OneTask.setActiveDownloadTaskList(downloadTaskList);

newGameTab.setNodeSupplier(loadVersionFor(() -> new VersionsPage(versionPageNavigator, i18n("install.installer.choose", i18n("install.installer.game")), "", DownloadProviders.getDownloadProvider(),
"game", versionPageNavigator::onGameSelected)));
modpackTab.setNodeSupplier(loadVersionFor(() -> {
Expand All @@ -99,31 +102,52 @@ public DownloadPage(String uploadVersion) {
page.getActions().add(installLocalModpackButton);
return page;
}));

//下面是设置搜索界面的
modTab.setNodeSupplier(loadVersionFor(() -> HMCLLocalizedDownloadListPage.ofMod((downloadProvider, profile, version, mod, file) -> download(downloadProvider, profile, version, file, "mods"), true)));
resourcePackTab.setNodeSupplier(loadVersionFor(() -> HMCLLocalizedDownloadListPage.ofResourcePack((downloadProvider, profile, version, mod, file) -> download(downloadProvider, profile, version, file, "resourcepacks"), true)));
shaderTab.setNodeSupplier(loadVersionFor(() -> HMCLLocalizedDownloadListPage.ofShaderPack((downloadProvider, profile, version, mod, file) -> download(downloadProvider, profile, version, file, "shaderpacks"), true)));
worldTab.setNodeSupplier(loadVersionFor(() -> new DownloadListPage(CurseForgeRemoteModRepository.WORLDS)));
tab = new TabHeader(transitionPane, newGameTab, modpackTab, modTab, resourcePackTab, shaderTab, worldTab);
downloadListTab.setNodeSupplier(() -> downloadTaskList);

Profiles.registerVersionsListener(this::loadVersions);

tab.select(newGameTab);

//这一堆规划了侧边栏的哪个按钮在哪个栏目
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议不要用中文

AdvancedListBox sideBar = new AdvancedListBox()
.startCategory(i18n("download.game").toUpperCase(Locale.ROOT))
.addNavigationDrawerTab(tab, newGameTab, i18n("game"), SVG.STADIA_CONTROLLER, SVG.STADIA_CONTROLLER_FILL)
.addNavigationDrawerTab(tab, modpackTab, i18n("modpack"), SVG.PACKAGE2, SVG.PACKAGE2_FILL)

.startCategory(i18n("download.content").toUpperCase(Locale.ROOT))
.addNavigationDrawerTab(tab, modTab, i18n("mods"), SVG.EXTENSION, SVG.EXTENSION_FILL)
.addNavigationDrawerTab(tab, resourcePackTab, i18n("resourcepack"), SVG.TEXTURE)
.addNavigationDrawerTab(tab, shaderTab, i18n("download.shader"), SVG.WB_SUNNY, SVG.WB_SUNNY_FILL)
.addNavigationDrawerTab(tab, worldTab, i18n("world"), SVG.PUBLIC);
.addNavigationDrawerTab(tab, worldTab, i18n("world"), SVG.PUBLIC)

.startCategory(i18n("download.others").toUpperCase(Locale.ROOT))
.addNavigationDrawerTab(tab, downloadListTab, i18n("download.task"), SVG.DOWNLOAD);

FXUtils.setLimitWidth(sideBar, 200);
setLeft(sideBar);

setCenter(transitionPane);
}

public DownloadTaskList getDownloadTaskList() {
return downloadTaskList;
}

public void addDownloadTask(TaskExecutor executor, String name) {
downloadTaskList.addDownloadEntry(executor, name);
}

public void addDownloadTask(Task<?> task) {
addDownloadTask(task.executor(), task.getName());
}

private static <T extends Node> Supplier<T> loadVersionFor(Supplier<T> nodeSupplier) {
return () -> {
T node = nodeSupplier.get();
Expand Down
Loading
Loading