alt: mod list now sorted by filename ignoring case

This commit is contained in:
huanghongxun
2020-03-20 21:08:28 +08:00
parent b2f6ef72c3
commit ac532c9400
2 changed files with 8 additions and 2 deletions

View File

@@ -104,7 +104,7 @@ public final class ModListPage extends ListPageBase<ModListPageSkin.ModInfoObjec
if (exception == null)
getProperties().put(ModListPage.class, FXUtils.onWeakChangeAndOperate(tab.selectedProperty(), newValue -> {
if (newValue)
itemsProperty().setAll(list.stream().map(ModListPageSkin.ModInfoObject::new).collect(Collectors.toList()));
itemsProperty().setAll(list.stream().map(ModListPageSkin.ModInfoObject::new).sorted().collect(Collectors.toList()));
}));
else
getProperties().remove(ModListPage.class);

View File

@@ -39,6 +39,7 @@ import org.jackhuang.hmcl.ui.SVG;
import org.jackhuang.hmcl.ui.construct.FloatListCell;
import org.jackhuang.hmcl.ui.construct.SpinnerPane;
import org.jackhuang.hmcl.ui.construct.TwoLineListItem;
import org.jetbrains.annotations.NotNull;
import static org.jackhuang.hmcl.ui.ToolbarListPageSkin.createToolbarButton;
import static org.jackhuang.hmcl.util.StringUtils.isNotBlank;
@@ -131,7 +132,7 @@ class ModListPageSkin extends SkinBase<ModListPage> {
getChildren().setAll(pane);
}
static class ModInfoObject extends RecursiveTreeObject<ModInfoObject> {
static class ModInfoObject extends RecursiveTreeObject<ModInfoObject> implements Comparable<ModInfoObject> {
private final BooleanProperty active;
private final ModInfo modInfo;
private final String message;
@@ -160,5 +161,10 @@ class ModListPageSkin extends SkinBase<ModListPage> {
ModInfo getModInfo() {
return modInfo;
}
@Override
public int compareTo(@NotNull ModListPageSkin.ModInfoObject o) {
return modInfo.getFileName().toLowerCase().compareTo(o.modInfo.getFileName().toLowerCase());
}
}
}