Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d9e2d92e0 | ||
|
|
9f754e78e8 | ||
|
|
cecd28791b | ||
|
|
5e42652e75 | ||
|
|
9f682e0c39 | ||
|
|
eac12efafb |
No files matched your search
@@ -39,7 +39,10 @@ public class JFXListViewSkin<T> extends ListViewSkin<T> {
|
|||||||
flow = (VirtualFlow<ListCell<T>>) getChildren().get(0);
|
flow = (VirtualFlow<ListCell<T>>) getChildren().get(0);
|
||||||
JFXDepthManager.setDepth(flow, listView.depthProperty().get());
|
JFXDepthManager.setDepth(flow, listView.depthProperty().get());
|
||||||
listView.depthProperty().addListener((o, oldVal, newVal) -> JFXDepthManager.setDepth(flow, newVal));
|
listView.depthProperty().addListener((o, oldVal, newVal) -> JFXDepthManager.setDepth(flow, newVal));
|
||||||
FXUtils.smoothScrolling(flow);
|
|
||||||
|
if (!Boolean.TRUE.equals(listView.getProperties().get("no-smooth-scrolling"))) {
|
||||||
|
FXUtils.smoothScrolling(flow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -204,6 +204,7 @@ public final class LogWindow extends Stage {
|
|||||||
LogWindowImpl() {
|
LogWindowImpl() {
|
||||||
getStyleClass().add("log-window");
|
getStyleClass().add("log-window");
|
||||||
|
|
||||||
|
listView.getProperties().put("no-smooth-scrolling", true);
|
||||||
listView.setItems(FXCollections.observableList(new CircularArrayList<>(logs.size())));
|
listView.setItems(FXCollections.observableList(new CircularArrayList<>(logs.size())));
|
||||||
|
|
||||||
for (int i = 0; i < LEVELS.length; i++) {
|
for (int i = 0; i < LEVELS.length; i++) {
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import javafx.animation.Animation.Status;
|
|||||||
import javafx.animation.KeyFrame;
|
import javafx.animation.KeyFrame;
|
||||||
import javafx.animation.Timeline;
|
import javafx.animation.Timeline;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
import javafx.scene.control.IndexedCell;
|
|
||||||
import javafx.scene.control.ScrollPane;
|
import javafx.scene.control.ScrollPane;
|
||||||
import javafx.scene.control.skin.VirtualFlow;
|
import javafx.scene.control.skin.VirtualFlow;
|
||||||
import javafx.scene.input.MouseEvent;
|
import javafx.scene.input.MouseEvent;
|
||||||
@@ -226,7 +225,6 @@ final class ScrollUtils {
|
|||||||
final double[] derivatives = new double[FRICTIONS.length];
|
final double[] derivatives = new double[FRICTIONS.length];
|
||||||
|
|
||||||
Timeline timeline = new Timeline();
|
Timeline timeline = new Timeline();
|
||||||
Holder<ScrollDirection> scrollDirectionHolder = new Holder<>();
|
|
||||||
final EventHandler<MouseEvent> mouseHandler = event -> timeline.stop();
|
final EventHandler<MouseEvent> mouseHandler = event -> timeline.stop();
|
||||||
final EventHandler<ScrollEvent> scrollHandler = event -> {
|
final EventHandler<ScrollEvent> scrollHandler = event -> {
|
||||||
if (event.getEventType() == ScrollEvent.SCROLL) {
|
if (event.getEventType() == ScrollEvent.SCROLL) {
|
||||||
@@ -234,7 +232,6 @@ final class ScrollUtils {
|
|||||||
if (scrollDirection == ScrollDirection.LEFT || scrollDirection == ScrollDirection.RIGHT) {
|
if (scrollDirection == ScrollDirection.LEFT || scrollDirection == ScrollDirection.RIGHT) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
scrollDirectionHolder.value = scrollDirection;
|
|
||||||
double currentSpeed = isTrackPad(event, scrollDirection) ? speed / trackPadAdjustment : speed;
|
double currentSpeed = isTrackPad(event, scrollDirection) ? speed / trackPadAdjustment : speed;
|
||||||
|
|
||||||
derivatives[0] += scrollDirection.intDirection * currentSpeed;
|
derivatives[0] += scrollDirection.intDirection * currentSpeed;
|
||||||
@@ -256,15 +253,7 @@ final class ScrollUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
double dy = derivatives[derivatives.length - 1];
|
double dy = derivatives[derivatives.length - 1];
|
||||||
|
virtualFlow.scrollPixels(dy);
|
||||||
int cellCount = virtualFlow.getCellCount();
|
|
||||||
IndexedCell<?> firstVisibleCell = virtualFlow.getFirstVisibleCell();
|
|
||||||
double height = firstVisibleCell != null ? firstVisibleCell.getHeight() * cellCount : 0.0;
|
|
||||||
|
|
||||||
double delta = height > 0.0
|
|
||||||
? dy / height
|
|
||||||
: (scrollDirectionHolder.value == ScrollDirection.DOWN ? 0.001 : -0.001);
|
|
||||||
virtualFlow.setPosition(Math.min(Math.max(virtualFlow.getPosition() + delta, 0), 1));
|
|
||||||
|
|
||||||
if (Math.abs(dy) < 0.001) {
|
if (Math.abs(dy) < 0.001) {
|
||||||
timeline.stop();
|
timeline.stop();
|
||||||
|
|||||||
+4
-1
@@ -22,6 +22,7 @@ import org.jackhuang.hmcl.download.RemoteVersion;
|
|||||||
import org.jackhuang.hmcl.download.VersionList;
|
import org.jackhuang.hmcl.download.VersionList;
|
||||||
import org.jackhuang.hmcl.task.GetTask;
|
import org.jackhuang.hmcl.task.GetTask;
|
||||||
import org.jackhuang.hmcl.task.Task;
|
import org.jackhuang.hmcl.task.Task;
|
||||||
|
import org.jackhuang.hmcl.util.gson.JsonUtils;
|
||||||
import org.jackhuang.hmcl.util.io.NetworkUtils;
|
import org.jackhuang.hmcl.util.io.NetworkUtils;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -64,11 +65,13 @@ public final class LiteLoaderBMCLVersionList extends VersionList<LiteLoaderRemot
|
|||||||
NetworkUtils.withQuery(downloadProvider.getApiRoot() + "/liteloader/list", Map.of(
|
NetworkUtils.withQuery(downloadProvider.getApiRoot() + "/liteloader/list", Map.of(
|
||||||
"mcversion", gameVersion
|
"mcversion", gameVersion
|
||||||
)))
|
)))
|
||||||
.thenGetJsonAsync(LiteLoaderBMCLVersion.class)
|
.thenApplyAsync(json -> JsonUtils.fromMaybeMalformedJson(json, LiteLoaderBMCLVersion.class))
|
||||||
.thenAcceptAsync(v -> {
|
.thenAcceptAsync(v -> {
|
||||||
lock.writeLock().lock();
|
lock.writeLock().lock();
|
||||||
try {
|
try {
|
||||||
versions.clear();
|
versions.clear();
|
||||||
|
if (v == null)
|
||||||
|
return;
|
||||||
versions.put(gameVersion, new LiteLoaderRemoteVersion(
|
versions.put(gameVersion, new LiteLoaderRemoteVersion(
|
||||||
gameVersion, v.version, RemoteVersion.Type.UNCATEGORIZED,
|
gameVersion, v.version, RemoteVersion.Type.UNCATEGORIZED,
|
||||||
Collections.singletonList(NetworkUtils.withQuery(
|
Collections.singletonList(NetworkUtils.withQuery(
|
||||||
|
|||||||
+7
-1
@@ -63,7 +63,13 @@ public final class NeoForgeOfficialVersionList extends VersionList<NeoForgeRemot
|
|||||||
if (majorVersion == 0) { // Snapshot version.
|
if (majorVersion == 0) { // Snapshot version.
|
||||||
mcVersion = version.substring(si1 + 1, si2);
|
mcVersion = version.substring(si1 + 1, si2);
|
||||||
} else {
|
} else {
|
||||||
mcVersion = "1." + version.substring(0, Integer.parseInt(version.substring(si1 + 1, si2)) == 0 ? si1 : si2);
|
String ver = version.substring(0, Integer.parseInt(version.substring(si1 + 1, si2)) == 0 ? si1 : si2);
|
||||||
|
if (majorVersion >= 26) {
|
||||||
|
int separator = version.indexOf('+');
|
||||||
|
mcVersion = separator < 0 ? ver : ver + "-" + version.substring(separator + 1);
|
||||||
|
} else {
|
||||||
|
mcVersion = "1." + ver;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
LOG.warning(String.format("Cannot parse NeoForge version %s for cracking its mc version.", version), e);
|
LOG.warning(String.format("Cannot parse NeoForge version %s for cracking its mc version.", version), e);
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ public class NeoForgeRemoteVersion extends RemoteVersion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Type getType(String version) {
|
private static Type getType(String version) {
|
||||||
return version.contains("beta") ? Type.SNAPSHOT : Type.RELEASE;
|
return version.contains("beta") || version.contains("alpha") ? Type.SNAPSHOT : Type.RELEASE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String normalize(String version) {
|
public static String normalize(String version) {
|
||||||
|
|||||||
+14
-10
@@ -114,16 +114,20 @@ public final class CurseForgeRemoteModRepository implements RemoteModRepository
|
|||||||
if (category != null && category.getSelf() instanceof CurseAddon.Category) {
|
if (category != null && category.getSelf() instanceof CurseAddon.Category) {
|
||||||
categoryId = ((CurseAddon.Category) category.getSelf()).getId();
|
categoryId = ((CurseAddon.Category) category.getSelf()).getId();
|
||||||
}
|
}
|
||||||
Response<List<CurseAddon>> response = withApiKey(HttpRequest.GET(downloadProvider.injectURL(NetworkUtils.withQuery(PREFIX + "/v1/mods/search", mapOf(
|
|
||||||
pair("gameId", "432"),
|
var query = new LinkedHashMap<String, String>();
|
||||||
pair("classId", Integer.toString(section)),
|
query.put("gameId", "432");
|
||||||
pair("categoryId", Integer.toString(categoryId)),
|
query.put("classId", Integer.toString(section));
|
||||||
pair("gameVersion", gameVersion),
|
if (categoryId != 0)
|
||||||
pair("searchFilter", searchFilter),
|
query.put("categoryId", Integer.toString(categoryId));
|
||||||
pair("sortField", Integer.toString(toModsSearchSortField(sortType))),
|
query.put("gameVersion", gameVersion);
|
||||||
pair("sortOrder", toSortOrder(sortOrder)),
|
query.put("searchFilter", searchFilter);
|
||||||
pair("index", Integer.toString(pageOffset * pageSize)),
|
query.put("sortField", Integer.toString(toModsSearchSortField(sortType)));
|
||||||
pair("pageSize", Integer.toString(pageSize)))))))
|
query.put("sortOrder", toSortOrder(sortOrder));
|
||||||
|
query.put("index", Integer.toString(pageOffset * pageSize));
|
||||||
|
query.put("pageSize", Integer.toString(pageSize));
|
||||||
|
|
||||||
|
Response<List<CurseAddon>> response = withApiKey(HttpRequest.GET(downloadProvider.injectURL(NetworkUtils.withQuery(PREFIX + "/v1/mods/search", query))))
|
||||||
.getJson(Response.typeOf(listTypeOf(CurseAddon.class)));
|
.getJson(Response.typeOf(listTypeOf(CurseAddon.class)));
|
||||||
if (searchFilter.isEmpty()) {
|
if (searchFilter.isEmpty()) {
|
||||||
return new SearchResult(response.getData().stream().map(CurseAddon::toMod), calculateTotalPages(response, pageSize));
|
return new SearchResult(response.getData().stream().map(CurseAddon::toMod), calculateTotalPages(response, pageSize));
|
||||||
|
|||||||
Reference in new issue
Block a user