feat(mod): only show buttons for selection when some mods selected.

This commit is contained in:
huanghongxun 2021-10-06 17:28:21 +08:00
parent e4a1fa5bb4
commit abae32fd70
7 changed files with 49 additions and 7 deletions

View File

@ -73,6 +73,12 @@ public final class SVG {
height);
}
public static Node cancel(ObjectBinding<? extends Paint> fill, double width, double height) {
return createSVGPath(
"M12 2C17.5 2 22 6.5 22 12S17.5 22 12 22 2 17.5 2 12 6.5 2 12 2M12 4C10.1 4 8.4 4.6 7.1 5.7L18.3 16.9C19.3 15.5 20 13.8 20 12C20 7.6 16.4 4 12 4M16.9 18.3L5.7 7.1C4.6 8.4 4 10.1 4 12C4 16.4 7.6 20 12 20C13.9 20 15.6 19.4 16.9 18.3Z",
fill, width, height);
}
public static Node close(ObjectBinding<? extends Paint> fill, double width, double height) {
return createSVGPath(
"M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z",
@ -526,4 +532,10 @@ public final class SVG {
"M19,15V3H23V15H19M15,3A2,2 0 0,1 17,5V15C17,15.55 16.78,16.05 16.41,16.41L9.83,23L8.77,21.94C8.5,21.67 8.33,21.3 8.33,20.88L8.36,20.57L9.31,16H3C1.89,16 1,15.1 1,14V12C1,11.74 1.05,11.5 1.14,11.27L4.16,4.22C4.46,3.5 5.17,3 6,3H15M15,5H5.97L3,12V14H11.78L10.65,19.32L15,14.97V5Z",
fill, width, height);
}
public static Node selectAll(ObjectBinding<? extends Paint> fill, double width, double height) {
return createSVGPath(
"M9,9H15V15H9M7,17H17V7H7M15,5H17V3H15M15,21H17V19H15M19,17H21V15H19M19,9H21V7H19M19,21A2,2 0 0,0 21,19H19M19,13H21V11H19M11,21H13V19H11M9,3H7V5H9M3,17H5V15H3M5,21V19H3A2,2 0 0,0 5,21M19,3V5H21A2,2 0 0,0 19,3M13,3H11V5H13M3,9H5V7H3M7,21H9V19H7M3,13H5V11H3M3,5H5V3A2,2 0 0,0 3,5Z",
fill, width, height);
}
}

View File

@ -222,6 +222,10 @@ public class DownloadPage extends DecoratorAnimatedPage implements DecoratorPage
tab.select(newGameTab);
}
public void showModDownloads() {
tab.select(modTab);
}
private class DownloadNavigator implements Navigation {
private final Map<String, Object> settings = new HashMap<>();

View File

@ -196,6 +196,11 @@ public final class ModListPage extends ListPageBase<ModListPageSkin.ModInfoObjec
});
}
public void download() {
Controllers.getDownloadPage().showModDownloads();
Controllers.navigate(Controllers.getDownloadPage());
}
public void rollback(LocalModFile from, LocalModFile to) {
try {
modManager.rollback(from, to);

View File

@ -39,6 +39,8 @@ import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.ui.Controllers;
import org.jackhuang.hmcl.ui.FXUtils;
import org.jackhuang.hmcl.ui.SVG;
import org.jackhuang.hmcl.ui.animation.ContainerAnimations;
import org.jackhuang.hmcl.ui.animation.TransitionPane;
import org.jackhuang.hmcl.ui.construct.*;
import org.jackhuang.hmcl.util.Lazy;
import org.jackhuang.hmcl.util.StringUtils;
@ -77,10 +79,19 @@ class ModListPageSkin extends SkinBase<ModListPage> {
JFXListView<ModInfoObject> listView = new JFXListView<>();
{
HBox toolbar = new HBox();
toolbar.getChildren().setAll(
TransitionPane toolBarPane = new TransitionPane();
HBox toolbarNormal = new HBox();
toolbarNormal.getChildren().setAll(
createToolbarButton2(i18n("button.refresh"), SVG::refresh, skinnable::refresh),
createToolbarButton2(i18n("mods.add"), SVG::plus, skinnable::add),
createToolbarButton2(i18n("folder.mod"), SVG::folderOpen, () ->
skinnable.openModFolder()),
createToolbarButton2(i18n("mods.check_updates"), SVG::update, () ->
skinnable.checkUpdates()),
createToolbarButton2(i18n("download"), SVG::downloadOutline, () ->
skinnable.download()));
HBox toolbarSelecting = new HBox();
toolbarSelecting.getChildren().setAll(
createToolbarButton2(i18n("button.remove"), SVG::delete, () -> {
Controllers.confirm(i18n("button.remove.confirm"), i18n("button.remove"), () -> {
skinnable.removeSelected(listView.getSelectionModel().getSelectedItems());
@ -90,11 +101,18 @@ class ModListPageSkin extends SkinBase<ModListPage> {
skinnable.enableSelected(listView.getSelectionModel().getSelectedItems())),
createToolbarButton2(i18n("mods.disable"), SVG::close, () ->
skinnable.disableSelected(listView.getSelectionModel().getSelectedItems())),
createToolbarButton2(i18n("folder.mod"), SVG::folderOpen, () ->
skinnable.openModFolder()),
createToolbarButton2(i18n("mods.check_updates"), SVG::update, () ->
skinnable.checkUpdates()));
root.getContent().add(toolbar);
createToolbarButton2(i18n("button.select_all"), SVG::selectAll, () ->
listView.getSelectionModel().selectAll()),
createToolbarButton2(i18n("button.cancel"), SVG::cancel, () ->
listView.getSelectionModel().clearSelection()));
FXUtils.onChangeAndOperate(listView.getSelectionModel().selectedItemProperty(), selectedItem -> {
if (selectedItem == null) {
toolBarPane.setContent(toolbarNormal, ContainerAnimations.FADE.getAnimationProducer());
} else {
toolBarPane.setContent(toolbarSelecting, ContainerAnimations.FADE.getAnimationProducer());
}
});
root.getContent().add(toolBarPane);
}
{

View File

@ -146,6 +146,7 @@ button.remove=Remove
button.remove.confirm=Are you sure you want to delete? You cannot roll back this operation!
button.save=Save
button.save_as=Save As
button.select_all=Select All
button.yes=Yes
color.recent=Recommended

View File

@ -146,6 +146,7 @@ button.remove=刪除
button.remove.confirm=您確認要刪除嗎?該操作無法撤銷!
button.save=儲存
button.save_as=另存為
button.select_all=全選
button.yes=
color.recent=建議

View File

@ -146,6 +146,7 @@ button.remove=删除
button.remove.confirm=您确定要删除吗?此操作无法撤销!
button.save=保存
button.save_as=另存为
button.select_all=全选
button.yes=
color.recent=推荐