Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e57a41c2f3 | ||
|
|
d63b0bb088 | ||
|
|
8e9ddfb248 | ||
|
|
1edd36819c | ||
|
|
a5f6028b3a | ||
|
|
52f57c783e |
No files matched your search
@@ -27,6 +27,7 @@ jobs:
|
||||
run: ./gradlew build --no-daemon --parallel
|
||||
env:
|
||||
MICROSOFT_AUTH_ID: ${{ secrets.MICROSOFT_AUTH_ID }}
|
||||
MICROSOFT_AUTH_SECRET: ${{ secrets.MICROSOFT_AUTH_SECRET }}
|
||||
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }}
|
||||
- name: Get short SHA
|
||||
run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV
|
||||
|
||||
@@ -15,7 +15,6 @@ hs_err_pid*
|
||||
NVIDIA
|
||||
minecraft-exported-crash-info*
|
||||
hmcl-exported-logs-*
|
||||
terracotta-log-*
|
||||
/.java/
|
||||
/.local/
|
||||
/.cache/
|
||||
|
||||
@@ -129,7 +129,6 @@ val addOpens = listOf(
|
||||
"javafx.base/javafx.beans.property",
|
||||
"javafx.graphics/javafx.css",
|
||||
"javafx.graphics/javafx.stage",
|
||||
"javafx.graphics/javafx.scene",
|
||||
"javafx.graphics/com.sun.glass.ui",
|
||||
"javafx.graphics/com.sun.javafx.stage",
|
||||
"javafx.graphics/com.sun.javafx.util",
|
||||
|
||||
@@ -1,169 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.jfoenix.controls;
|
||||
|
||||
import com.jfoenix.skins.JFXCheckBoxSkin;
|
||||
import javafx.css.*;
|
||||
import javafx.css.converter.PaintConverter;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.Skin;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.paint.Paint;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/// JFXCheckBox is the material design implementation of a checkbox.
|
||||
/// it shows ripple effect and a custom selection animation.
|
||||
///
|
||||
/// @author Shadi Shaheen
|
||||
/// @version 1.0
|
||||
/// @since 2016-03-09
|
||||
public class JFXCheckBox extends CheckBox {
|
||||
|
||||
public JFXCheckBox(String text) {
|
||||
super(text);
|
||||
initialize();
|
||||
}
|
||||
|
||||
public JFXCheckBox() {
|
||||
initialize();
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
this.getStyleClass().add(DEFAULT_STYLE_CLASS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Skin<?> createDefaultSkin() {
|
||||
return new JFXCheckBoxSkin(this);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* Stylesheet Handling *
|
||||
* *
|
||||
**************************************************************************/
|
||||
|
||||
/// Initialize the style class to 'jfx-check-box'.
|
||||
///
|
||||
/// This is the selector class from which CSS can be used to style
|
||||
/// this control.
|
||||
private static final String DEFAULT_STYLE_CLASS = "jfx-check-box";
|
||||
|
||||
/// checkbox color property when selected
|
||||
private StyleableObjectProperty<Paint> checkedColor;
|
||||
|
||||
private static final Color DEFAULT_CHECKED_COLOR = Color.valueOf("#0F9D58");
|
||||
|
||||
public StyleableObjectProperty<Paint> checkedColorProperty() {
|
||||
if (checkedColor == null) {
|
||||
checkedColor = new SimpleStyleableObjectProperty<>(StyleableProperties.CHECKED_COLOR,
|
||||
JFXCheckBox.this,
|
||||
"checkedColor",
|
||||
DEFAULT_CHECKED_COLOR);
|
||||
}
|
||||
return this.checkedColor;
|
||||
}
|
||||
|
||||
public Paint getCheckedColor() {
|
||||
return checkedColor == null ? DEFAULT_CHECKED_COLOR : checkedColor.get();
|
||||
}
|
||||
|
||||
public void setCheckedColor(Paint color) {
|
||||
this.checkedColor.set(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* checkbox color property when not selected
|
||||
*/
|
||||
private StyleableObjectProperty<Paint> unCheckedColor;
|
||||
|
||||
private static final Color DEFAULT_UNCHECKED_COLOR = Color.valueOf("#5A5A5A");
|
||||
|
||||
public StyleableObjectProperty<Paint> unCheckedColorProperty() {
|
||||
if (unCheckedColor == null) {
|
||||
unCheckedColor = new SimpleStyleableObjectProperty<>(StyleableProperties.UNCHECKED_COLOR,
|
||||
JFXCheckBox.this,
|
||||
"unCheckedColor",
|
||||
DEFAULT_UNCHECKED_COLOR);
|
||||
}
|
||||
return this.unCheckedColor;
|
||||
}
|
||||
|
||||
public Paint getUnCheckedColor() {
|
||||
return unCheckedColor == null ? DEFAULT_UNCHECKED_COLOR : unCheckedColor.get();
|
||||
}
|
||||
|
||||
public void setUnCheckedColor(Paint color) {
|
||||
this.unCheckedColor.set(color);
|
||||
}
|
||||
|
||||
private static final class StyleableProperties {
|
||||
private static final CssMetaData<JFXCheckBox, Paint> CHECKED_COLOR =
|
||||
new CssMetaData<>("-jfx-checked-color",
|
||||
PaintConverter.getInstance(), DEFAULT_CHECKED_COLOR) {
|
||||
@Override
|
||||
public boolean isSettable(JFXCheckBox control) {
|
||||
return control.checkedColor == null || !control.checkedColor.isBound();
|
||||
}
|
||||
|
||||
@Override
|
||||
public StyleableProperty<Paint> getStyleableProperty(JFXCheckBox control) {
|
||||
return control.checkedColorProperty();
|
||||
}
|
||||
};
|
||||
private static final CssMetaData<JFXCheckBox, Paint> UNCHECKED_COLOR =
|
||||
new CssMetaData<>("-jfx-unchecked-color",
|
||||
PaintConverter.getInstance(), DEFAULT_UNCHECKED_COLOR) {
|
||||
@Override
|
||||
public boolean isSettable(JFXCheckBox control) {
|
||||
return control.unCheckedColor == null || !control.unCheckedColor.isBound();
|
||||
}
|
||||
|
||||
@Override
|
||||
public StyleableProperty<Paint> getStyleableProperty(JFXCheckBox control) {
|
||||
return control.unCheckedColorProperty();
|
||||
}
|
||||
};
|
||||
private static final List<CssMetaData<? extends Styleable, ?>> CHILD_STYLEABLES;
|
||||
|
||||
static {
|
||||
final List<CssMetaData<? extends Styleable, ?>> styleables =
|
||||
new ArrayList<>(CheckBox.getClassCssMetaData());
|
||||
Collections.addAll(styleables,
|
||||
CHECKED_COLOR,
|
||||
UNCHECKED_COLOR
|
||||
);
|
||||
CHILD_STYLEABLES = List.copyOf(styleables);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CssMetaData<? extends Styleable, ?>> getControlCssMetaData() {
|
||||
return getClassCssMetaData();
|
||||
}
|
||||
|
||||
public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData() {
|
||||
return StyleableProperties.CHILD_STYLEABLES;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by Fernflower decompiler)
|
||||
//
|
||||
|
||||
package com.jfoenix.controls;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Orientation;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.layout.FlowPane;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
|
||||
public class JFXDialogLayout extends StackPane {
|
||||
private final StackPane heading = new StackPane();
|
||||
private final StackPane body = new StackPane();
|
||||
private final FlowPane actions = new FlowPane() {
|
||||
protected double computeMinWidth(double height) {
|
||||
if (this.getContentBias() == Orientation.HORIZONTAL) {
|
||||
double maxPref = 0.0;
|
||||
for (Node child : this.getChildren()) {
|
||||
if (child.isManaged()) {
|
||||
maxPref = Math.max(maxPref, child.minWidth(-1.0));
|
||||
}
|
||||
}
|
||||
|
||||
Insets insets = this.getInsets();
|
||||
return insets.getLeft() + this.snapSizeX(maxPref) + insets.getRight();
|
||||
} else {
|
||||
return this.computePrefWidth(height);
|
||||
}
|
||||
}
|
||||
|
||||
protected double computeMinHeight(double width) {
|
||||
if (this.getContentBias() == Orientation.VERTICAL) {
|
||||
double maxPref = 0.0;
|
||||
|
||||
for (Node child : this.getChildren()) {
|
||||
if (child.isManaged()) {
|
||||
maxPref = Math.max(maxPref, child.minHeight(-1.0));
|
||||
}
|
||||
}
|
||||
|
||||
Insets insets = this.getInsets();
|
||||
return insets.getTop() + this.snapSizeY(maxPref) + insets.getBottom();
|
||||
} else {
|
||||
return this.computePrefHeight(width);
|
||||
}
|
||||
}
|
||||
};
|
||||
private static final String DEFAULT_STYLE_CLASS = "jfx-dialog-layout";
|
||||
|
||||
public JFXDialogLayout() {
|
||||
this.getStyleClass().add(DEFAULT_STYLE_CLASS);
|
||||
|
||||
VBox layout = new VBox();
|
||||
|
||||
this.heading.getStyleClass().add("jfx-layout-heading");
|
||||
this.heading.getStyleClass().add("title");
|
||||
|
||||
this.body.getStyleClass().add("jfx-layout-body");
|
||||
this.body.prefHeightProperty().bind(this.prefHeightProperty());
|
||||
this.body.prefWidthProperty().bind(this.prefWidthProperty());
|
||||
|
||||
this.actions.getStyleClass().add("jfx-layout-actions");
|
||||
|
||||
layout.getChildren().setAll(this.heading, this.body, this.actions);
|
||||
|
||||
this.getChildren().add(layout);
|
||||
}
|
||||
|
||||
public ObservableList<Node> getHeading() {
|
||||
return this.heading.getChildren();
|
||||
}
|
||||
|
||||
public void setHeading(Node... titleContent) {
|
||||
this.heading.getChildren().setAll(titleContent);
|
||||
}
|
||||
|
||||
public ObservableList<Node> getBody() {
|
||||
return this.body.getChildren();
|
||||
}
|
||||
|
||||
public void setBody(Node... body) {
|
||||
this.body.getChildren().setAll(body);
|
||||
}
|
||||
|
||||
public ObservableList<Node> getActions() {
|
||||
return this.actions.getChildren();
|
||||
}
|
||||
|
||||
public void setActions(Node... actions) {
|
||||
this.actions.getChildren().setAll(actions);
|
||||
}
|
||||
|
||||
public void setActions(List<? extends Node> actions) {
|
||||
this.actions.getChildren().setAll(actions);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,271 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.jfoenix.controls;
|
||||
|
||||
import com.jfoenix.utils.JFXNodeUtils;
|
||||
import javafx.animation.Interpolator;
|
||||
import javafx.animation.KeyFrame;
|
||||
import javafx.animation.KeyValue;
|
||||
import javafx.animation.Timeline;
|
||||
import javafx.application.Platform;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ListCell;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.scene.shape.Rectangle;
|
||||
import javafx.scene.shape.Shape;
|
||||
import javafx.util.Duration;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/// material design implementation of ListCell
|
||||
///
|
||||
/// By default, JFXListCell will try to create a graphic node for the cell,
|
||||
/// to override it you need to set graphic to null in [#updateItem(Object, boolean)] method.
|
||||
///
|
||||
/// NOTE: passive nodes (Labels and Shapes) will be set to mouse transparent in order to
|
||||
/// show the ripple effect upon clicking , to change this behavior you can override the
|
||||
/// method {[#makeChildrenTransparent()]
|
||||
///
|
||||
/// @author Shadi Shaheen
|
||||
/// @version 1.0
|
||||
/// @since 2016-03-09
|
||||
public class JFXListCell<T> extends ListCell<T> {
|
||||
|
||||
protected JFXRippler cellRippler = new JFXRippler(this) {
|
||||
@Override
|
||||
protected Node getMask() {
|
||||
Region clip = new Region();
|
||||
JFXNodeUtils.updateBackground(JFXListCell.this.getBackground(), clip);
|
||||
double width = control.getLayoutBounds().getWidth();
|
||||
double height = control.getLayoutBounds().getHeight();
|
||||
clip.resize(width, height);
|
||||
return clip;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void positionControl(Node control) {
|
||||
// do nothing
|
||||
}
|
||||
};
|
||||
|
||||
protected Node cellContent;
|
||||
private Rectangle clip;
|
||||
|
||||
private Timeline gapAnimation;
|
||||
private boolean playExpandAnimation = false;
|
||||
private boolean selectionChanged = false;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public JFXListCell() {
|
||||
initialize();
|
||||
initListeners();
|
||||
}
|
||||
|
||||
/**
|
||||
* init listeners to update the vertical gap / selection animation
|
||||
*/
|
||||
private void initListeners() {
|
||||
listViewProperty().addListener((listObj, oldList, newList) -> {
|
||||
if (newList instanceof JFXListView<?> listView) {
|
||||
listView.currentVerticalGapProperty().addListener((o, oldVal, newVal) -> {
|
||||
cellRippler.rippler.setClip(null);
|
||||
if (newVal.doubleValue() != 0) {
|
||||
playExpandAnimation = true;
|
||||
getListView().requestLayout();
|
||||
} else {
|
||||
// fake expand state
|
||||
double gap = clip.getY() * 2;
|
||||
gapAnimation = new Timeline(
|
||||
new KeyFrame(Duration.millis(240),
|
||||
new KeyValue(this.translateYProperty(),
|
||||
-gap / 2 - (gap * (getIndex())),
|
||||
Interpolator.EASE_BOTH)
|
||||
));
|
||||
gapAnimation.play();
|
||||
gapAnimation.setOnFinished((finish) -> {
|
||||
requestLayout();
|
||||
Platform.runLater(() -> getListView().requestLayout());
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
selectedProperty().addListener((o, oldVal, newVal) -> {
|
||||
if (newVal) {
|
||||
selectionChanged = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void layoutChildren() {
|
||||
super.layoutChildren();
|
||||
cellRippler.resizeRelocate(0, 0, getWidth(), getHeight());
|
||||
double gap = getGap();
|
||||
|
||||
if (clip == null) {
|
||||
clip = new Rectangle(0, gap / 2, getWidth(), getHeight() - gap);
|
||||
setClip(clip);
|
||||
} else {
|
||||
if (gap != 0) {
|
||||
if (playExpandAnimation || selectionChanged) {
|
||||
// fake list collapse state
|
||||
if (playExpandAnimation) {
|
||||
this.setTranslateY(-gap / 2 + (-gap * (getIndex())));
|
||||
clip.setY(gap / 2);
|
||||
clip.setHeight(getHeight() - gap);
|
||||
gapAnimation = new Timeline(new KeyFrame(Duration.millis(240),
|
||||
new KeyValue(this.translateYProperty(),
|
||||
0,
|
||||
Interpolator.EASE_BOTH)));
|
||||
playExpandAnimation = false;
|
||||
} else if (selectionChanged) {
|
||||
clip.setY(0);
|
||||
clip.setHeight(getHeight());
|
||||
gapAnimation = new Timeline(
|
||||
new KeyFrame(Duration.millis(240),
|
||||
new KeyValue(clip.yProperty(), gap / 2, Interpolator.EASE_BOTH),
|
||||
new KeyValue(clip.heightProperty(), getHeight() - gap, Interpolator.EASE_BOTH)
|
||||
));
|
||||
}
|
||||
playExpandAnimation = false;
|
||||
selectionChanged = false;
|
||||
gapAnimation.play();
|
||||
} else {
|
||||
if (gapAnimation != null) {
|
||||
gapAnimation.stop();
|
||||
}
|
||||
this.setTranslateY(0);
|
||||
clip.setY(gap / 2);
|
||||
clip.setHeight(getHeight() - gap);
|
||||
}
|
||||
} else {
|
||||
this.setTranslateY(0);
|
||||
clip.setY(0);
|
||||
clip.setHeight(getHeight());
|
||||
}
|
||||
clip.setX(0);
|
||||
clip.setWidth(getWidth());
|
||||
}
|
||||
if (!getChildren().contains(cellRippler)) {
|
||||
makeChildrenTransparent();
|
||||
getChildren().add(0, cellRippler);
|
||||
cellRippler.rippler.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* this method is used to set some nodes in cell content as mouse transparent nodes
|
||||
* so clicking on them will trigger the ripple effect.
|
||||
*/
|
||||
protected void makeChildrenTransparent() {
|
||||
for (Node child : getChildren()) {
|
||||
if (child instanceof Label) {
|
||||
Set<Node> texts = child.lookupAll("Text");
|
||||
for (Node text : texts) {
|
||||
text.setMouseTransparent(true);
|
||||
}
|
||||
} else if (child instanceof Shape) {
|
||||
child.setMouseTransparent(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void updateItem(T item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (empty) {
|
||||
setText(null);
|
||||
setGraphic(null);
|
||||
// remove empty (Trailing cells)
|
||||
setMouseTransparent(true);
|
||||
setStyle("-fx-background-color:TRANSPARENT;");
|
||||
} else {
|
||||
setMouseTransparent(false);
|
||||
setStyle(null);
|
||||
if (item instanceof Node newNode) {
|
||||
setText(null);
|
||||
Node currentNode = getGraphic();
|
||||
if (currentNode == null || !currentNode.equals(newNode)) {
|
||||
cellContent = newNode;
|
||||
cellRippler.rippler.cacheRippleClip(false);
|
||||
// build the Cell node
|
||||
// RIPPLER ITEM : in case if the list item has its own rippler bind the list rippler and item rippler properties
|
||||
if (newNode instanceof JFXRippler newRippler) {
|
||||
// build cell container from exisiting rippler
|
||||
cellRippler.ripplerFillProperty().bind(newRippler.ripplerFillProperty());
|
||||
cellRippler.maskTypeProperty().bind(newRippler.maskTypeProperty());
|
||||
cellRippler.positionProperty().bind(newRippler.positionProperty());
|
||||
cellContent = newRippler.getControl();
|
||||
}
|
||||
((Region) cellContent).setMaxHeight(cellContent.prefHeight(-1));
|
||||
setGraphic(cellContent);
|
||||
}
|
||||
} else {
|
||||
setText(item == null ? "null" : item.toString());
|
||||
setGraphic(null);
|
||||
}
|
||||
// show cell tooltip if it's toggled in JFXListView
|
||||
if (getListView() instanceof JFXListView<?> listView && listView.isShowTooltip()) {
|
||||
if (item instanceof Label label) {
|
||||
setTooltip(new Tooltip(label.getText()));
|
||||
} else if (getText() != null) {
|
||||
setTooltip(new Tooltip(getText()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Stylesheet Handling *
|
||||
|
||||
/**
|
||||
* Initialize the style class to 'jfx-list-cell'.
|
||||
* <p>
|
||||
* This is the selector class from which CSS can be used to style
|
||||
* this control.
|
||||
*/
|
||||
private static final String DEFAULT_STYLE_CLASS = "jfx-list-cell";
|
||||
|
||||
private void initialize() {
|
||||
this.getStyleClass().add(DEFAULT_STYLE_CLASS);
|
||||
this.setPadding(new Insets(8, 12, 8, 12));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double computePrefHeight(double width) {
|
||||
double gap = getGap();
|
||||
return super.computePrefHeight(width) + gap;
|
||||
}
|
||||
|
||||
private double getGap() {
|
||||
return (getListView() instanceof JFXListView<?> listView)
|
||||
? (listView.isExpanded() ? listView.currentVerticalGapProperty().get() : 0)
|
||||
: 0;
|
||||
}
|
||||
}
|
||||
@@ -1,258 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.jfoenix.controls;
|
||||
|
||||
import com.jfoenix.skins.JFXListViewSkin;
|
||||
import javafx.beans.property.*;
|
||||
import javafx.css.*;
|
||||
import javafx.css.converter.BooleanConverter;
|
||||
import javafx.css.converter.SizeConverter;
|
||||
import javafx.scene.control.ListView;
|
||||
import javafx.scene.control.Skin;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/// Material design implementation of List View
|
||||
///
|
||||
/// @author Shadi Shaheen
|
||||
/// @version 1.0
|
||||
/// @since 2016-03-09
|
||||
public class JFXListView<T> extends ListView<T> {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public JFXListView() {
|
||||
this.setCellFactory(listView -> new JFXListCell<>());
|
||||
initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Skin<?> createDefaultSkin() {
|
||||
return new JFXListViewSkin<>(this);
|
||||
}
|
||||
|
||||
private IntegerProperty depth;
|
||||
|
||||
public IntegerProperty depthProperty() {
|
||||
if (depth == null) {
|
||||
depth = new SimpleIntegerProperty(this, "depth", 0);
|
||||
}
|
||||
return depth;
|
||||
}
|
||||
|
||||
public int getDepth() {
|
||||
return depth != null ? depth.get() : 0;
|
||||
}
|
||||
|
||||
public void setDepth(int depth) {
|
||||
depthProperty().set(depth);
|
||||
}
|
||||
|
||||
private DoubleProperty currentVerticalGap;
|
||||
|
||||
DoubleProperty currentVerticalGapProperty() {
|
||||
if (currentVerticalGap == null) {
|
||||
currentVerticalGap = new SimpleDoubleProperty(this, "currentVerticalGap");
|
||||
}
|
||||
return currentVerticalGap;
|
||||
}
|
||||
|
||||
private void updateVerticalGap() {
|
||||
if (isExpanded()) {
|
||||
currentVerticalGapProperty().set(verticalGap.get());
|
||||
} else {
|
||||
currentVerticalGapProperty().set(0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* this only works if the items were labels / strings
|
||||
*/
|
||||
private BooleanProperty showTooltip;
|
||||
|
||||
public final BooleanProperty showTooltipProperty() {
|
||||
if (showTooltip == null) {
|
||||
showTooltip = new SimpleBooleanProperty(this, "showTooltip", false);
|
||||
}
|
||||
return this.showTooltip;
|
||||
}
|
||||
|
||||
public final boolean isShowTooltip() {
|
||||
return showTooltip != null && showTooltip.get();
|
||||
}
|
||||
|
||||
public final void setShowTooltip(final boolean showTooltip) {
|
||||
this.showTooltipProperty().set(showTooltip);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* Stylesheet Handling *
|
||||
* *
|
||||
**************************************************************************/
|
||||
|
||||
/// Initialize the style class to 'jfx-list-view'.
|
||||
///
|
||||
/// This is the selector class from which CSS can be used to style
|
||||
/// this control.
|
||||
private static final String DEFAULT_STYLE_CLASS = "jfx-list-view";
|
||||
|
||||
private void initialize() {
|
||||
this.getStyleClass().add(DEFAULT_STYLE_CLASS);
|
||||
}
|
||||
|
||||
/**
|
||||
* propagate mouse events to the parent node ( e.g. to allow dragging while clicking on the list)
|
||||
*/
|
||||
public void propagateMouseEventsToParent() {
|
||||
this.addEventHandler(MouseEvent.ANY, e -> {
|
||||
e.consume();
|
||||
this.getParent().fireEvent(e);
|
||||
});
|
||||
}
|
||||
|
||||
private StyleableDoubleProperty verticalGap;
|
||||
|
||||
public StyleableDoubleProperty verticalGapProperty() {
|
||||
if (this.verticalGap == null) {
|
||||
this.verticalGap = new StyleableDoubleProperty(0.0) {
|
||||
@Override
|
||||
public Object getBean() {
|
||||
return JFXListView.this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "verticalGap";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CssMetaData<? extends Styleable, Number> getCssMetaData() {
|
||||
return StyleableProperties.VERTICAL_GAP;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void invalidated() {
|
||||
updateVerticalGap();
|
||||
}
|
||||
};
|
||||
}
|
||||
return this.verticalGap;
|
||||
}
|
||||
|
||||
public Double getVerticalGap() {
|
||||
return verticalGap == null ? 0.0 : verticalGap.get();
|
||||
}
|
||||
|
||||
public void setVerticalGap(Double gap) {
|
||||
verticalGapProperty().set(gap);
|
||||
}
|
||||
|
||||
private StyleableBooleanProperty expanded;
|
||||
|
||||
public StyleableBooleanProperty expandedProperty() {
|
||||
if (expanded == null) {
|
||||
expanded = new StyleableBooleanProperty(false) {
|
||||
@Override
|
||||
public Object getBean() {
|
||||
return JFXListView.this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "expanded";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CssMetaData<? extends Styleable, Boolean> getCssMetaData() {
|
||||
return StyleableProperties.EXPANDED;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void invalidated() {
|
||||
updateVerticalGap();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return this.expanded;
|
||||
}
|
||||
|
||||
public Boolean isExpanded() {
|
||||
return expanded != null && expanded.get();
|
||||
}
|
||||
|
||||
public void setExpanded(Boolean expanded) {
|
||||
expandedProperty().set(expanded);
|
||||
}
|
||||
|
||||
private static final class StyleableProperties {
|
||||
private static final CssMetaData<JFXListView<?>, Number> VERTICAL_GAP =
|
||||
new CssMetaData<>("-jfx-vertical-gap",
|
||||
SizeConverter.getInstance(), 0) {
|
||||
@Override
|
||||
public boolean isSettable(JFXListView<?> control) {
|
||||
return control.verticalGap == null || !control.verticalGap.isBound();
|
||||
}
|
||||
|
||||
@Override
|
||||
public StyleableDoubleProperty getStyleableProperty(JFXListView<?> control) {
|
||||
return control.verticalGapProperty();
|
||||
}
|
||||
};
|
||||
private static final CssMetaData<JFXListView<?>, Boolean> EXPANDED =
|
||||
new CssMetaData<>("-jfx-expanded",
|
||||
BooleanConverter.getInstance(), false) {
|
||||
@Override
|
||||
public boolean isSettable(JFXListView<?> control) {
|
||||
// it's only settable if the List is not shown yet
|
||||
return control.getHeight() == 0 && (control.expanded == null || !control.expanded.isBound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public StyleableBooleanProperty getStyleableProperty(JFXListView<?> control) {
|
||||
return control.expandedProperty();
|
||||
}
|
||||
};
|
||||
private static final List<CssMetaData<? extends Styleable, ?>> CHILD_STYLEABLES;
|
||||
|
||||
static {
|
||||
final List<CssMetaData<? extends Styleable, ?>> styleables =
|
||||
new ArrayList<>(ListView.getClassCssMetaData());
|
||||
Collections.addAll(styleables, VERTICAL_GAP, EXPANDED);
|
||||
CHILD_STYLEABLES = List.copyOf(styleables);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CssMetaData<? extends Styleable, ?>> getControlCssMetaData() {
|
||||
return getClassCssMetaData();
|
||||
}
|
||||
|
||||
public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData() {
|
||||
return StyleableProperties.CHILD_STYLEABLES;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.jfoenix.controls;
|
||||
|
||||
import com.jfoenix.skins.JFXProgressBarSkin;
|
||||
import javafx.beans.property.DoubleProperty;
|
||||
import javafx.beans.property.SimpleDoubleProperty;
|
||||
import javafx.scene.control.ProgressBar;
|
||||
import javafx.scene.control.Skin;
|
||||
|
||||
/// JFXProgressBar is the material design implementation of a progress bar.
|
||||
///
|
||||
/// @author Shadi Shaheen
|
||||
/// @version 1.0
|
||||
/// @since 2016-03-09
|
||||
public class JFXProgressBar extends ProgressBar {
|
||||
/// Initialize the style class to 'jfx-progress-bar'.
|
||||
///
|
||||
/// This is the selector class from which CSS can be used to style
|
||||
/// this control.
|
||||
private static final String DEFAULT_STYLE_CLASS = "jfx-progress-bar";
|
||||
|
||||
public JFXProgressBar() {
|
||||
initialize();
|
||||
}
|
||||
|
||||
public JFXProgressBar(double progress) {
|
||||
super(progress);
|
||||
initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Skin<?> createDefaultSkin() {
|
||||
return new JFXProgressBarSkin(this);
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
setPrefWidth(200);
|
||||
getStyleClass().add(DEFAULT_STYLE_CLASS);
|
||||
}
|
||||
|
||||
|
||||
private DoubleProperty secondaryProgress;
|
||||
|
||||
public DoubleProperty secondaryProgressProperty() {
|
||||
if (secondaryProgress == null) {
|
||||
secondaryProgress = new SimpleDoubleProperty(this, "secondaryProgress", INDETERMINATE_PROGRESS);
|
||||
}
|
||||
return secondaryProgress;
|
||||
}
|
||||
|
||||
public double getSecondaryProgress() {
|
||||
return secondaryProgress == null ? INDETERMINATE_PROGRESS : secondaryProgress.get();
|
||||
}
|
||||
|
||||
public void setSecondaryProgress(double secondaryProgress) {
|
||||
secondaryProgressProperty().set(secondaryProgress);
|
||||
}
|
||||
}
|
||||
@@ -1,160 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.jfoenix.controls;
|
||||
|
||||
import com.jfoenix.skins.JFXRadioButtonSkin;
|
||||
import javafx.css.*;
|
||||
import javafx.css.converter.ColorConverter;
|
||||
import javafx.scene.control.RadioButton;
|
||||
import javafx.scene.control.Skin;
|
||||
import javafx.scene.paint.Color;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/// JFXRadioButton is the material design implementation of a radio button.
|
||||
///
|
||||
/// @author Bashir Elias & Shadi Shaheen
|
||||
/// @version 1.0
|
||||
/// @since 2016-03-09
|
||||
public class JFXRadioButton extends RadioButton {
|
||||
|
||||
public JFXRadioButton(String text) {
|
||||
super(text);
|
||||
initialize();
|
||||
}
|
||||
|
||||
public JFXRadioButton() {
|
||||
initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Skin<?> createDefaultSkin() {
|
||||
return new JFXRadioButtonSkin(this);
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
this.getStyleClass().add(DEFAULT_STYLE_CLASS);
|
||||
}
|
||||
|
||||
/// Initialize the style class to 'jfx-radio-button'.
|
||||
///
|
||||
/// This is the selector class from which CSS can be used to style
|
||||
/// this control.
|
||||
private static final String DEFAULT_STYLE_CLASS = "jfx-radio-button";
|
||||
|
||||
/// default color used when the radio button is selected
|
||||
private StyleableObjectProperty<Color> selectedColor;
|
||||
|
||||
private static final Color DEFAULT_SELECTED_COLOR = Color.valueOf("#0F9D58");
|
||||
|
||||
public final StyleableObjectProperty<Color> selectedColorProperty() {
|
||||
if (selectedColor == null) {
|
||||
selectedColor = new SimpleStyleableObjectProperty<>(StyleableProperties.SELECTED_COLOR,
|
||||
JFXRadioButton.this,
|
||||
"selectedColor",
|
||||
DEFAULT_SELECTED_COLOR);
|
||||
}
|
||||
return this.selectedColor;
|
||||
}
|
||||
|
||||
public final Color getSelectedColor() {
|
||||
return selectedColor == null ? DEFAULT_SELECTED_COLOR : this.selectedColorProperty().get();
|
||||
}
|
||||
|
||||
public final void setSelectedColor(final Color selectedColor) {
|
||||
this.selectedColorProperty().set(selectedColor);
|
||||
}
|
||||
|
||||
/// default color used when the radio button is not selected
|
||||
private StyleableObjectProperty<Color> unSelectedColor;
|
||||
|
||||
private static final Color DEFAULT_UNSELECTED_COLOR = Color.valueOf("#5A5A5A");
|
||||
|
||||
public final StyleableObjectProperty<Color> unSelectedColorProperty() {
|
||||
if (unSelectedColor == null) {
|
||||
unSelectedColor = new SimpleStyleableObjectProperty<>(
|
||||
StyleableProperties.UNSELECTED_COLOR,
|
||||
JFXRadioButton.this,
|
||||
"unSelectedColor",
|
||||
DEFAULT_UNSELECTED_COLOR);
|
||||
}
|
||||
return this.unSelectedColor;
|
||||
}
|
||||
|
||||
public final Color getUnSelectedColor() {
|
||||
return unSelectedColor == null ? DEFAULT_UNSELECTED_COLOR : this.unSelectedColorProperty().get();
|
||||
}
|
||||
|
||||
public final void setUnSelectedColor(final Color unSelectedColor) {
|
||||
this.unSelectedColorProperty().set(unSelectedColor);
|
||||
}
|
||||
|
||||
private static final class StyleableProperties {
|
||||
private static final CssMetaData<JFXRadioButton, Color> SELECTED_COLOR =
|
||||
new CssMetaData<JFXRadioButton, Color>("-jfx-selected-color",
|
||||
ColorConverter.getInstance(), DEFAULT_SELECTED_COLOR) {
|
||||
@Override
|
||||
public boolean isSettable(JFXRadioButton control) {
|
||||
return control.selectedColor == null || !control.selectedColor.isBound();
|
||||
}
|
||||
|
||||
@Override
|
||||
public StyleableProperty<Color> getStyleableProperty(JFXRadioButton control) {
|
||||
return control.selectedColorProperty();
|
||||
}
|
||||
};
|
||||
private static final CssMetaData<JFXRadioButton, Color> UNSELECTED_COLOR =
|
||||
new CssMetaData<JFXRadioButton, Color>("-jfx-unselected-color",
|
||||
ColorConverter.getInstance(), DEFAULT_UNSELECTED_COLOR) {
|
||||
@Override
|
||||
public boolean isSettable(JFXRadioButton control) {
|
||||
return control.unSelectedColor == null || !control.unSelectedColor.isBound();
|
||||
}
|
||||
|
||||
@Override
|
||||
public StyleableProperty<Color> getStyleableProperty(JFXRadioButton control) {
|
||||
return control.unSelectedColorProperty();
|
||||
}
|
||||
};
|
||||
|
||||
private static final List<CssMetaData<? extends Styleable, ?>> CHILD_STYLEABLES;
|
||||
|
||||
static {
|
||||
final List<CssMetaData<? extends Styleable, ?>> styleables =
|
||||
new ArrayList<>(RadioButton.getClassCssMetaData());
|
||||
Collections.addAll(styleables,
|
||||
SELECTED_COLOR,
|
||||
UNSELECTED_COLOR
|
||||
);
|
||||
CHILD_STYLEABLES = List.copyOf(styleables);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CssMetaData<? extends Styleable, ?>> getControlCssMetaData() {
|
||||
return getClassCssMetaData();
|
||||
}
|
||||
|
||||
public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData() {
|
||||
return StyleableProperties.CHILD_STYLEABLES;
|
||||
}
|
||||
}
|
||||
@@ -1,180 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.jfoenix.controls;
|
||||
|
||||
import com.jfoenix.converters.IndicatorPositionConverter;
|
||||
import com.jfoenix.skins.JFXSliderSkin;
|
||||
import javafx.beans.binding.StringBinding;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.css.*;
|
||||
import javafx.scene.control.Skin;
|
||||
import javafx.scene.control.Slider;
|
||||
import javafx.util.Callback;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/// JFXSlider is the material design implementation of a slider.
|
||||
///
|
||||
/// @author Bashir Elias & Shadi Shaheen
|
||||
/// @version 1.0
|
||||
/// @since 2016-03-09
|
||||
public class JFXSlider extends Slider {
|
||||
|
||||
public JFXSlider() {
|
||||
super(0, 100, 50);
|
||||
initialize();
|
||||
}
|
||||
|
||||
public JFXSlider(double min, double max, double value) {
|
||||
super(min, max, value);
|
||||
initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Skin<?> createDefaultSkin() {
|
||||
return new JFXSliderSkin(this);
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
getStyleClass().add(DEFAULT_STYLE_CLASS);
|
||||
}
|
||||
|
||||
public enum IndicatorPosition {
|
||||
LEFT, RIGHT
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* Properties *
|
||||
* *
|
||||
**************************************************************************/
|
||||
|
||||
/// String binding factory for the slider value.
|
||||
/// Sets a custom string for the value text (by default, it shows the value rounded to the nearest whole number).
|
||||
///
|
||||
///
|
||||
/// For example, to have the value displayed as a percentage (assuming the slider has a range of (0, 100)):
|
||||
/// ```java
|
||||
/// JFXSlider mySlider = ...
|
||||
/// mySlider.setValueFactory(slider ->
|
||||
/// Bindings.createStringBinding(
|
||||
/// () -> ((int) slider.getValue()) + "%",
|
||||
/// slider.valueProperty()
|
||||
/// )
|
||||
/// );
|
||||
/// ```
|
||||
///
|
||||
/// NOTE: might be replaced later with a call back to create the animated thumb node
|
||||
///
|
||||
/// @param callback a callback to create the string value binding
|
||||
private ObjectProperty<Callback<JFXSlider, StringBinding>> valueFactory;
|
||||
|
||||
public final ObjectProperty<Callback<JFXSlider, StringBinding>> valueFactoryProperty() {
|
||||
if (valueFactory == null) {
|
||||
valueFactory = new SimpleObjectProperty<>(this, "valueFactory");
|
||||
}
|
||||
return valueFactory;
|
||||
}
|
||||
|
||||
/// @return the current slider value factory
|
||||
public final Callback<JFXSlider, StringBinding> getValueFactory() {
|
||||
return valueFactory == null ? null : valueFactory.get();
|
||||
}
|
||||
|
||||
/// sets custom string binding for the slider text value
|
||||
///
|
||||
/// @param valueFactory a callback to create the string value binding
|
||||
public final void setValueFactory(final Callback<JFXSlider, StringBinding> valueFactory) {
|
||||
this.valueFactoryProperty().set(valueFactory);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* Stylesheet Handling *
|
||||
* *
|
||||
**************************************************************************/
|
||||
|
||||
/// Initialize the style class to 'jfx-slider'.
|
||||
///
|
||||
/// This is the selector class from which CSS can be used to style
|
||||
/// this control.
|
||||
private static final String DEFAULT_STYLE_CLASS = "jfx-slider";
|
||||
|
||||
/// indicates the position of the slider indicator, can be
|
||||
/// either LEFT or RIGHT
|
||||
private StyleableObjectProperty<IndicatorPosition> indicatorPosition;
|
||||
|
||||
public StyleableObjectProperty<IndicatorPosition> indicatorPositionProperty() {
|
||||
if (indicatorPosition == null) {
|
||||
indicatorPosition = new SimpleStyleableObjectProperty<>(
|
||||
StyleableProperties.INDICATOR_POSITION,
|
||||
JFXSlider.this,
|
||||
"indicatorPosition",
|
||||
IndicatorPosition.LEFT);
|
||||
}
|
||||
return this.indicatorPosition;
|
||||
}
|
||||
|
||||
public IndicatorPosition getIndicatorPosition() {
|
||||
return indicatorPosition == null ? IndicatorPosition.LEFT : indicatorPosition.get();
|
||||
}
|
||||
|
||||
public void setIndicatorPosition(IndicatorPosition pos) {
|
||||
indicatorPositionProperty().set(pos);
|
||||
}
|
||||
|
||||
private static final class StyleableProperties {
|
||||
private static final CssMetaData<JFXSlider, IndicatorPosition> INDICATOR_POSITION = new CssMetaData<>(
|
||||
"-jfx-indicator-position",
|
||||
IndicatorPositionConverter.getInstance(),
|
||||
IndicatorPosition.LEFT) {
|
||||
@Override
|
||||
public boolean isSettable(JFXSlider control) {
|
||||
return control.indicatorPosition == null || !control.indicatorPosition.isBound();
|
||||
}
|
||||
|
||||
@Override
|
||||
public StyleableProperty<IndicatorPosition> getStyleableProperty(JFXSlider control) {
|
||||
return control.indicatorPositionProperty();
|
||||
}
|
||||
};
|
||||
|
||||
private static final List<CssMetaData<? extends Styleable, ?>> CHILD_STYLEABLES;
|
||||
|
||||
static {
|
||||
final List<CssMetaData<? extends Styleable, ?>> styleables = new ArrayList<>(
|
||||
Slider.getClassCssMetaData());
|
||||
Collections.addAll(styleables, INDICATOR_POSITION);
|
||||
CHILD_STYLEABLES = List.copyOf(styleables);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CssMetaData<? extends Styleable, ?>> getControlCssMetaData() {
|
||||
return getClassCssMetaData();
|
||||
}
|
||||
|
||||
public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData() {
|
||||
return StyleableProperties.CHILD_STYLEABLES;
|
||||
}
|
||||
}
|
||||
@@ -1,168 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.jfoenix.controls;
|
||||
|
||||
import com.jfoenix.skins.JFXSpinnerSkin;
|
||||
import javafx.css.CssMetaData;
|
||||
import javafx.css.SimpleStyleableDoubleProperty;
|
||||
import javafx.css.Styleable;
|
||||
import javafx.css.StyleableDoubleProperty;
|
||||
import javafx.css.converter.SizeConverter;
|
||||
import javafx.scene.control.ProgressIndicator;
|
||||
import javafx.scene.control.Skin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/// JFXSpinner is the material design implementation of a loading spinner.
|
||||
///
|
||||
/// @author Bashir Elias & Shadi Shaheen
|
||||
/// @version 1.0
|
||||
/// @since 2016-03-09
|
||||
public class JFXSpinner extends ProgressIndicator {
|
||||
|
||||
public static final double INDETERMINATE_PROGRESS = ProgressIndicator.INDETERMINATE_PROGRESS;
|
||||
|
||||
public JFXSpinner() {
|
||||
this(INDETERMINATE_PROGRESS);
|
||||
}
|
||||
|
||||
public JFXSpinner(double progress) {
|
||||
super(progress);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
getStyleClass().add(DEFAULT_STYLE_CLASS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Skin<?> createDefaultSkin() {
|
||||
return new JFXSpinnerSkin(this);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* Stylesheet Handling *
|
||||
* *
|
||||
**************************************************************************/
|
||||
|
||||
/// Initialize the style class to 'jfx-spinner'.
|
||||
///
|
||||
/// This is the selector class from which CSS can be used to style
|
||||
/// this control.
|
||||
private static final String DEFAULT_STYLE_CLASS = "jfx-spinner";
|
||||
|
||||
private static final double DEFAULT_RADIUS = 12.0;
|
||||
|
||||
/**
|
||||
* specifies the radius of the spinner node, by default it's set to `12.0`
|
||||
*/
|
||||
private StyleableDoubleProperty radius;
|
||||
|
||||
public final StyleableDoubleProperty radiusProperty() {
|
||||
if (this.radius == null) {
|
||||
this.radius = new SimpleStyleableDoubleProperty(StyleableProperties.RADIUS,
|
||||
JFXSpinner.this,
|
||||
"radius",
|
||||
DEFAULT_RADIUS);
|
||||
}
|
||||
return this.radius;
|
||||
}
|
||||
|
||||
public final double getRadius() {
|
||||
return radius != null ? radius.get() : DEFAULT_RADIUS;
|
||||
}
|
||||
|
||||
public final void setRadius(final double radius) {
|
||||
this.radiusProperty().set(radius);
|
||||
}
|
||||
|
||||
/// specifies from which angle the spinner should start spinning
|
||||
private StyleableDoubleProperty startingAngle;
|
||||
|
||||
public final StyleableDoubleProperty startingAngleProperty() {
|
||||
if (this.startingAngle == null) {
|
||||
startingAngle = new SimpleStyleableDoubleProperty(StyleableProperties.STARTING_ANGLE,
|
||||
JFXSpinner.this,
|
||||
"startingAngle",
|
||||
0.0);
|
||||
}
|
||||
return this.startingAngle;
|
||||
}
|
||||
|
||||
public final double getStartingAngle() {
|
||||
return startingAngle != null ? startingAngle.get() : 0.0;
|
||||
}
|
||||
|
||||
public final void setStartingAngle(final double startingAngle) {
|
||||
this.startingAngleProperty().set(startingAngle);
|
||||
}
|
||||
|
||||
private static final class StyleableProperties {
|
||||
private static final CssMetaData<JFXSpinner, Number> RADIUS =
|
||||
new CssMetaData<>("-jfx-radius",
|
||||
SizeConverter.getInstance(), DEFAULT_RADIUS) {
|
||||
@Override
|
||||
public boolean isSettable(JFXSpinner control) {
|
||||
return control.radius == null || !control.radius.isBound();
|
||||
}
|
||||
|
||||
@Override
|
||||
public StyleableDoubleProperty getStyleableProperty(JFXSpinner control) {
|
||||
return control.radiusProperty();
|
||||
}
|
||||
};
|
||||
|
||||
private static final CssMetaData<JFXSpinner, Number> STARTING_ANGLE =
|
||||
new CssMetaData<>("-jfx-starting-angle",
|
||||
SizeConverter.getInstance(), 0.0) {
|
||||
@Override
|
||||
public boolean isSettable(JFXSpinner control) {
|
||||
return control.startingAngle == null || !control.startingAngle.isBound();
|
||||
}
|
||||
|
||||
@Override
|
||||
public StyleableDoubleProperty getStyleableProperty(JFXSpinner control) {
|
||||
return control.startingAngleProperty();
|
||||
}
|
||||
};
|
||||
|
||||
private static final List<CssMetaData<? extends Styleable, ?>> CHILD_STYLEABLES;
|
||||
|
||||
static {
|
||||
final List<CssMetaData<? extends Styleable, ?>> styleables =
|
||||
new ArrayList<>(ProgressIndicator.getClassCssMetaData());
|
||||
Collections.addAll(styleables, RADIUS, STARTING_ANGLE);
|
||||
CHILD_STYLEABLES = List.copyOf(styleables);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CssMetaData<? extends Styleable, ?>> getControlCssMetaData() {
|
||||
return getClassCssMetaData();
|
||||
}
|
||||
|
||||
public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData() {
|
||||
return StyleableProperties.CHILD_STYLEABLES;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.jfoenix.controls;
|
||||
|
||||
import com.jfoenix.utils.JFXNodeUtils;
|
||||
import javafx.beans.InvalidationListener;
|
||||
import javafx.beans.WeakInvalidationListener;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.TreeCell;
|
||||
import javafx.scene.control.TreeItem;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.scene.paint.Color;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
/// JFXTreeCell is simple material design implementation of a tree cell.
|
||||
///
|
||||
/// @author Shadi Shaheen
|
||||
/// @version 1.0
|
||||
/// @since 2017-02-15
|
||||
public class JFXTreeCell<T> extends TreeCell<T> {
|
||||
|
||||
protected JFXRippler cellRippler = new JFXRippler(this) {
|
||||
@Override
|
||||
protected Node getMask() {
|
||||
Region clip = new Region();
|
||||
JFXNodeUtils.updateBackground(JFXTreeCell.this.getBackground(), clip);
|
||||
double width = control.getLayoutBounds().getWidth();
|
||||
double height = control.getLayoutBounds().getHeight();
|
||||
clip.resize(width, height);
|
||||
return clip;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void positionControl(Node control) {
|
||||
// do nothing
|
||||
}
|
||||
};
|
||||
private HBox hbox;
|
||||
private final StackPane selectedPane = new StackPane();
|
||||
|
||||
private final InvalidationListener treeItemGraphicInvalidationListener = observable -> updateDisplay(getItem(),
|
||||
isEmpty());
|
||||
private final WeakInvalidationListener weakTreeItemGraphicListener = new WeakInvalidationListener(
|
||||
treeItemGraphicInvalidationListener);
|
||||
|
||||
private WeakReference<TreeItem<T>> treeItemRef;
|
||||
|
||||
public JFXTreeCell() {
|
||||
selectedPane.getStyleClass().add("selection-bar");
|
||||
selectedPane.setBackground(new Background(new BackgroundFill(Color.RED, CornerRadii.EMPTY, Insets.EMPTY)));
|
||||
selectedPane.setPrefWidth(3);
|
||||
selectedPane.setMouseTransparent(true);
|
||||
selectedProperty().addListener((o, oldVal, newVal) -> selectedPane.setVisible(newVal ? true : false));
|
||||
|
||||
final InvalidationListener treeItemInvalidationListener = observable -> {
|
||||
TreeItem<T> oldTreeItem = treeItemRef == null ? null : treeItemRef.get();
|
||||
if (oldTreeItem != null) {
|
||||
oldTreeItem.graphicProperty().removeListener(weakTreeItemGraphicListener);
|
||||
}
|
||||
|
||||
TreeItem<T> newTreeItem = getTreeItem();
|
||||
if (newTreeItem != null) {
|
||||
newTreeItem.graphicProperty().addListener(weakTreeItemGraphicListener);
|
||||
treeItemRef = new WeakReference<>(newTreeItem);
|
||||
}
|
||||
};
|
||||
final WeakInvalidationListener weakTreeItemListener = new WeakInvalidationListener(treeItemInvalidationListener);
|
||||
treeItemProperty().addListener(weakTreeItemListener);
|
||||
if (getTreeItem() != null) {
|
||||
getTreeItem().graphicProperty().addListener(weakTreeItemGraphicListener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void layoutChildren() {
|
||||
super.layoutChildren();
|
||||
if (!getChildren().contains(selectedPane)) {
|
||||
getChildren().add(0, cellRippler);
|
||||
cellRippler.rippler.clear();
|
||||
getChildren().add(0, selectedPane);
|
||||
}
|
||||
cellRippler.resizeRelocate(0, 0, getWidth(), getHeight());
|
||||
cellRippler.releaseRipple();
|
||||
selectedPane.resizeRelocate(0, 0, selectedPane.prefWidth(-1), getHeight());
|
||||
selectedPane.setVisible(isSelected());
|
||||
}
|
||||
|
||||
private void updateDisplay(T item, boolean empty) {
|
||||
if (item == null || empty) {
|
||||
hbox = null;
|
||||
setText(null);
|
||||
setGraphic(null);
|
||||
} else {
|
||||
TreeItem<T> treeItem = getTreeItem();
|
||||
if (treeItem != null && treeItem.getGraphic() != null) {
|
||||
if (item instanceof Node) {
|
||||
setText(null);
|
||||
if (hbox == null) {
|
||||
hbox = new HBox(3);
|
||||
}
|
||||
hbox.getChildren().setAll(treeItem.getGraphic(), (Node) item);
|
||||
setGraphic(hbox);
|
||||
} else {
|
||||
hbox = null;
|
||||
setText(item.toString());
|
||||
setGraphic(treeItem.getGraphic());
|
||||
}
|
||||
} else {
|
||||
hbox = null;
|
||||
if (item instanceof Node) {
|
||||
setText(null);
|
||||
setGraphic((Node) item);
|
||||
} else {
|
||||
setText(item.toString());
|
||||
setGraphic(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateItem(T item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
updateDisplay(item, empty);
|
||||
setMouseTransparent(item == null || empty);
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.jfoenix.controls;
|
||||
|
||||
import javafx.scene.control.TreeItem;
|
||||
import javafx.scene.control.TreeView;
|
||||
|
||||
/// JFXTreeView is the material design implementation of a TreeView
|
||||
/// with expand/collapse animation and selection indicator.
|
||||
///
|
||||
/// @author Shadi Shaheen
|
||||
/// @version 1.0
|
||||
/// @since 2017-02-15
|
||||
public class JFXTreeView<T> extends TreeView<T> {
|
||||
|
||||
private static final String DEFAULT_STYLE_CLASS = "jfx-tree-view";
|
||||
|
||||
public JFXTreeView() {
|
||||
init();
|
||||
}
|
||||
|
||||
public JFXTreeView(TreeItem<T> root) {
|
||||
super(root);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
this.setCellFactory((view) -> new JFXTreeCell<>());
|
||||
this.getStyleClass().add(DEFAULT_STYLE_CLASS);
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.jfoenix.controls.datamodels.treetable;
|
||||
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.scene.control.TreeTableColumn;
|
||||
|
||||
/// data model that is used in JFXTreeTableView, it's used to implement
|
||||
/// the grouping feature.
|
||||
///
|
||||
/// **Note:** the data object used in JFXTreeTableView **must** extends this class
|
||||
///
|
||||
/// @param <T> is the concrete object of the Tree table
|
||||
/// @author Shadi Shaheen
|
||||
/// @version 1.0
|
||||
/// @since 2016-03-09
|
||||
public class RecursiveTreeObject<T> {
|
||||
|
||||
/// grouped children objects
|
||||
private ObservableList<T> children = FXCollections.observableArrayList();
|
||||
|
||||
public ObservableList<T> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(ObservableList<T> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
/// Whether or not the object is grouped by a specified tree table column
|
||||
ObjectProperty<TreeTableColumn<T, ?>> groupedColumn = new SimpleObjectProperty<>();
|
||||
|
||||
public final ObjectProperty<TreeTableColumn<T, ?>> groupedColumnProperty() {
|
||||
return this.groupedColumn;
|
||||
}
|
||||
|
||||
public final TreeTableColumn<T, ?> getGroupedColumn() {
|
||||
return this.groupedColumnProperty().get();
|
||||
}
|
||||
|
||||
public final void setGroupedColumn(final TreeTableColumn<T, ?> groupedColumn) {
|
||||
this.groupedColumnProperty().set(groupedColumn);
|
||||
}
|
||||
|
||||
/// the value that must be shown when grouped
|
||||
ObjectProperty<Object> groupedValue = new SimpleObjectProperty<>();
|
||||
|
||||
public final ObjectProperty<Object> groupedValueProperty() {
|
||||
return this.groupedValue;
|
||||
}
|
||||
|
||||
public final Object getGroupedValue() {
|
||||
return this.groupedValueProperty().get();
|
||||
}
|
||||
|
||||
public final void setGroupedValue(final Object groupedValue) {
|
||||
this.groupedValueProperty().set(groupedValue);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.jfoenix.controls.events;
|
||||
|
||||
import javafx.event.Event;
|
||||
import javafx.event.EventType;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/// JFXDialog events, used exclusively by the following methods:
|
||||
///
|
||||
/// - [com.jfoenix.controls.JFXDialog#show()]
|
||||
/// - [com.jfoenix.controls.JFXDialog#close()]
|
||||
///
|
||||
/// @author Shadi Shaheen
|
||||
/// @version 1.0
|
||||
/// @since 2016-03-09
|
||||
public class JFXDialogEvent extends Event {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/// This event occurs when a JFXDialog is closed, no longer visible to the user
|
||||
/// ( after the exit animation ends )
|
||||
public static final EventType<JFXDialogEvent> CLOSED = new EventType<>(Event.ANY, "JFX_DIALOG_CLOSED");
|
||||
|
||||
/// This event occurs when a JFXDialog is opened, visible to the user
|
||||
/// ( after the entrance animation ends )
|
||||
public static final EventType<JFXDialogEvent> OPENED = new EventType<>(Event.ANY, "JFX_DIALOG_OPENED");
|
||||
|
||||
/// Construct a new JFXDialog `Event` with the specified event type
|
||||
///
|
||||
/// @param eventType the event type
|
||||
public JFXDialogEvent(EventType<? extends Event> eventType) {
|
||||
super(eventType);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,7 +32,8 @@ public class JFXListViewSkin<T> extends ListViewSkin<T> {
|
||||
public JFXListViewSkin(final JFXListView<T> listView) {
|
||||
super(listView);
|
||||
VirtualFlow<ListCell<T>> flow = getVirtualFlow();
|
||||
FXUtils.onChangeAndOperate(listView.depthProperty(), depth -> JFXDepthManager.setDepth(flow, depth.intValue()));
|
||||
JFXDepthManager.setDepth(flow, listView.depthProperty().get());
|
||||
listView.depthProperty().addListener((o, oldVal, newVal) -> JFXDepthManager.setDepth(flow, newVal));
|
||||
|
||||
if (!Boolean.TRUE.equals(listView.getProperties().get("no-smooth-scrolling"))) {
|
||||
FXUtils.smoothScrolling(flow);
|
||||
|
||||
@@ -1,224 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.jfoenix.skins;
|
||||
|
||||
import com.jfoenix.controls.JFXProgressBar;
|
||||
import com.jfoenix.utils.JFXNodeUtils;
|
||||
import com.jfoenix.utils.TreeShowingProperty;
|
||||
import javafx.animation.*;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.ProgressIndicator;
|
||||
import javafx.scene.control.skin.ProgressIndicatorSkin;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.util.Duration;
|
||||
|
||||
/// # Material Design ProgressBar Skin
|
||||
///
|
||||
/// @author Shadi Shaheen
|
||||
/// @version 2.0
|
||||
/// @since 2017-10-06
|
||||
public class JFXProgressBarSkin extends ProgressIndicatorSkin {
|
||||
|
||||
private StackPane track;
|
||||
private StackPane secondaryBar;
|
||||
private StackPane bar;
|
||||
private double barWidth = 0;
|
||||
private double secondaryBarWidth = 0;
|
||||
private Timeline indeterminateTransition;
|
||||
private Region clip;
|
||||
private final TreeShowingProperty treeShowingProperty;
|
||||
|
||||
public JFXProgressBarSkin(JFXProgressBar bar) {
|
||||
super(bar);
|
||||
|
||||
this.treeShowingProperty = new TreeShowingProperty(bar);
|
||||
|
||||
bar.widthProperty().addListener(observable -> {
|
||||
updateProgress();
|
||||
updateSecondaryProgress();
|
||||
});
|
||||
|
||||
registerChangeListener(bar.progressProperty(), (obs) -> updateProgress());
|
||||
registerChangeListener(bar.secondaryProgressProperty(), obs -> updateSecondaryProgress());
|
||||
registerChangeListener(bar.visibleProperty(), obs -> updateAnimation());
|
||||
registerChangeListener(bar.parentProperty(), obs -> updateAnimation());
|
||||
registerChangeListener(bar.sceneProperty(), obs -> updateAnimation());
|
||||
|
||||
unregisterChangeListeners(treeShowingProperty);
|
||||
unregisterChangeListeners(bar.indeterminateProperty());
|
||||
|
||||
registerChangeListener(treeShowingProperty, obs -> this.updateAnimation());
|
||||
registerChangeListener(bar.indeterminateProperty(), obs -> initialize());
|
||||
|
||||
initialize();
|
||||
|
||||
getSkinnable().requestLayout();
|
||||
}
|
||||
|
||||
protected void initialize() {
|
||||
|
||||
track = new StackPane();
|
||||
track.getStyleClass().setAll("track");
|
||||
|
||||
bar = new StackPane();
|
||||
bar.getStyleClass().setAll("bar");
|
||||
|
||||
secondaryBar = new StackPane();
|
||||
secondaryBar.getStyleClass().setAll("secondary-bar");
|
||||
|
||||
clip = new Region();
|
||||
clip.setBackground(new Background(new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY)));
|
||||
bar.backgroundProperty().addListener(observable -> JFXNodeUtils.updateBackground(bar.getBackground(), clip));
|
||||
|
||||
getChildren().setAll(track, secondaryBar, bar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double computeBaselineOffset(double topInset, double rightInset, double bottomInset, double leftInset) {
|
||||
return Node.BASELINE_OFFSET_SAME_AS_HEIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
|
||||
return Math.max(100, leftInset + bar.prefWidth(getSkinnable().getWidth()) + rightInset);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
|
||||
return topInset + bar.prefHeight(width) + bottomInset;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double computeMaxWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
|
||||
return getSkinnable().prefWidth(height);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double computeMaxHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
|
||||
return getSkinnable().prefHeight(width);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void layoutChildren(double x, double y, double w, double h) {
|
||||
track.resizeRelocate(x, y, w, h);
|
||||
secondaryBar.resizeRelocate(x, y, secondaryBarWidth, h);
|
||||
bar.resizeRelocate(x, y, getSkinnable().isIndeterminate() ? w : barWidth, h);
|
||||
clip.resizeRelocate(0, 0, w, h);
|
||||
|
||||
if (getSkinnable().isIndeterminate()) {
|
||||
createIndeterminateTimeline();
|
||||
if (JFXNodeUtils.isTreeShowing(getSkinnable())) {
|
||||
indeterminateTransition.play();
|
||||
}
|
||||
// apply clip
|
||||
bar.setClip(clip);
|
||||
} else if (indeterminateTransition != null) {
|
||||
clearAnimation();
|
||||
// remove clip
|
||||
bar.setClip(null);
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateSecondaryProgress() {
|
||||
final JFXProgressBar control = (JFXProgressBar) getSkinnable();
|
||||
secondaryBarWidth = ((int) (control.getWidth() - snappedLeftInset() - snappedRightInset()) * 2
|
||||
* Math.min(1, Math.max(0, control.getSecondaryProgress()))) / 2.0F;
|
||||
control.requestLayout();
|
||||
}
|
||||
|
||||
boolean wasIndeterminate = false;
|
||||
|
||||
protected void pauseTimeline(boolean pause) {
|
||||
if (getSkinnable().isIndeterminate()) {
|
||||
if (indeterminateTransition == null) {
|
||||
createIndeterminateTimeline();
|
||||
}
|
||||
if (pause) {
|
||||
indeterminateTransition.pause();
|
||||
} else {
|
||||
indeterminateTransition.play();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAnimation() {
|
||||
final boolean isTreeShowing = treeShowingProperty.get();
|
||||
if (indeterminateTransition != null) {
|
||||
pauseTimeline(!isTreeShowing);
|
||||
} else if (isTreeShowing) {
|
||||
createIndeterminateTimeline();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateProgress() {
|
||||
final ProgressIndicator control = getSkinnable();
|
||||
final boolean isIndeterminate = control.isIndeterminate();
|
||||
if (!(isIndeterminate && wasIndeterminate)) {
|
||||
barWidth = ((int) (control.getWidth() - snappedLeftInset() - snappedRightInset()) * 2
|
||||
* Math.min(1, Math.max(0, control.getProgress()))) / 2.0F;
|
||||
control.requestLayout();
|
||||
}
|
||||
wasIndeterminate = isIndeterminate;
|
||||
}
|
||||
|
||||
private void createIndeterminateTimeline() {
|
||||
if (indeterminateTransition != null) {
|
||||
clearAnimation();
|
||||
}
|
||||
double dur = 1;
|
||||
ProgressIndicator control = getSkinnable();
|
||||
final double w = control.getWidth() - (snappedLeftInset() + snappedRightInset());
|
||||
indeterminateTransition = new Timeline(new KeyFrame(
|
||||
Duration.ZERO,
|
||||
new KeyValue(clip.scaleXProperty(), 0.0, Interpolator.EASE_IN),
|
||||
new KeyValue(clip.translateXProperty(), -w / 2, Interpolator.LINEAR)
|
||||
),
|
||||
new KeyFrame(
|
||||
Duration.seconds(0.5 * dur),
|
||||
new KeyValue(clip.scaleXProperty(), 0.4, Interpolator.LINEAR)
|
||||
),
|
||||
new KeyFrame(
|
||||
Duration.seconds(0.9 * dur),
|
||||
new KeyValue(clip.translateXProperty(), w / 2, Interpolator.LINEAR)
|
||||
),
|
||||
new KeyFrame(
|
||||
Duration.seconds(1 * dur),
|
||||
new KeyValue(clip.scaleXProperty(), 0.0, Interpolator.EASE_OUT)
|
||||
));
|
||||
indeterminateTransition.setCycleCount(Timeline.INDEFINITE);
|
||||
}
|
||||
|
||||
private void clearAnimation() {
|
||||
indeterminateTransition.stop();
|
||||
indeterminateTransition.getKeyFrames().clear();
|
||||
indeterminateTransition = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
treeShowingProperty.dispose();
|
||||
if (indeterminateTransition != null) {
|
||||
clearAnimation();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,291 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.jfoenix.skins;
|
||||
|
||||
import com.jfoenix.controls.JFXSlider;
|
||||
import com.jfoenix.controls.JFXSlider.IndicatorPosition;
|
||||
import javafx.animation.Interpolator;
|
||||
import javafx.animation.KeyFrame;
|
||||
import javafx.animation.KeyValue;
|
||||
import javafx.animation.Timeline;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.property.DoubleProperty;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.css.PseudoClass;
|
||||
import javafx.geometry.Orientation;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.chart.NumberAxis;
|
||||
import javafx.scene.control.Slider;
|
||||
import javafx.scene.control.skin.SliderSkin;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.util.Duration;
|
||||
|
||||
/// # Material Design Slider Skin
|
||||
///
|
||||
/// rework of JFXSliderSkin by extending Java SliderSkin
|
||||
/// this solves padding and resizing issues
|
||||
///
|
||||
/// @author Shadi Shaheen
|
||||
/// @version 1.0
|
||||
/// @since 2016-03-09
|
||||
public class JFXSliderSkin extends SliderSkin {
|
||||
|
||||
private static final PseudoClass MIN_VALUE = PseudoClass.getPseudoClass("min");
|
||||
private static final PseudoClass MAX_VALUE = PseudoClass.getPseudoClass("max");
|
||||
|
||||
private final Pane mouseHandlerPane = new Pane();
|
||||
private final Text sliderValue;
|
||||
private final StackPane coloredTrack;
|
||||
private final StackPane thumb;
|
||||
private final StackPane track;
|
||||
private final StackPane animatedThumb;
|
||||
private NumberAxis tickLine;
|
||||
|
||||
private Timeline timeline;
|
||||
|
||||
private double indicatorRotation;
|
||||
private double horizontalRotation;
|
||||
private double shifting;
|
||||
|
||||
public JFXSliderSkin(JFXSlider slider) {
|
||||
super(slider);
|
||||
|
||||
track = (StackPane) getSkinnable().lookup(".track");
|
||||
thumb = (StackPane) getSkinnable().lookup(".thumb");
|
||||
tickLine = (NumberAxis) getSkinnable().lookup(".axis");
|
||||
if (tickLine != null) tickLine.setAnimated(false);
|
||||
|
||||
coloredTrack = new StackPane();
|
||||
coloredTrack.getStyleClass().add("colored-track");
|
||||
coloredTrack.setMouseTransparent(true);
|
||||
|
||||
sliderValue = new Text();
|
||||
sliderValue.getStyleClass().setAll("slider-value");
|
||||
|
||||
animatedThumb = new StackPane();
|
||||
animatedThumb.getStyleClass().add("animated-thumb");
|
||||
animatedThumb.getChildren().add(sliderValue);
|
||||
animatedThumb.setMouseTransparent(true);
|
||||
animatedThumb.setScaleX(0);
|
||||
animatedThumb.setScaleY(0);
|
||||
|
||||
thumb.layoutXProperty().addListener(x -> {
|
||||
if (slider.getOrientation() == Orientation.VERTICAL) initAnimation(Orientation.VERTICAL);
|
||||
});
|
||||
thumb.layoutYProperty().addListener(y -> {
|
||||
if (slider.getOrientation() == Orientation.HORIZONTAL) initAnimation(Orientation.HORIZONTAL);
|
||||
});
|
||||
|
||||
addJFXChildren();
|
||||
getChildren().addListener((ListChangeListener<Node>) c -> {
|
||||
while (c.next()) {
|
||||
if (c.wasAdded()) {
|
||||
c.getAddedSubList().forEach(added -> {
|
||||
if (added instanceof NumberAxis) {
|
||||
tickLine = (NumberAxis) added;
|
||||
tickLine.setAnimated(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
registerChangeListener(slider.showTickMarksProperty(), e -> addJFXChildren());
|
||||
registerChangeListener(slider.showTickLabelsProperty(), e -> addJFXChildren());
|
||||
registerChangeListener(slider.valueFactoryProperty(), obs -> refreshSliderValueBinding());
|
||||
|
||||
initListeners();
|
||||
}
|
||||
|
||||
private void addJFXChildren() {
|
||||
ObservableList<Node> children = getChildren();
|
||||
Slider slider = getSkinnable();
|
||||
if ((slider.isShowTickMarks() || slider.isShowTickLabels()) && tickLine != null && !children.contains(tickLine)) {
|
||||
children.add(0, tickLine);
|
||||
}
|
||||
if (children.contains(coloredTrack)) return;
|
||||
children.add(children.indexOf(thumb), coloredTrack);
|
||||
children.add(children.indexOf(thumb), animatedThumb);
|
||||
children.add(0, mouseHandlerPane);
|
||||
}
|
||||
|
||||
private void refreshSliderValueBinding() {
|
||||
sliderValue.textProperty().unbind();
|
||||
if (((JFXSlider) getSkinnable()).getValueFactory() != null) {
|
||||
sliderValue.textProperty()
|
||||
.bind(((JFXSlider) getSkinnable()).getValueFactory().call((JFXSlider) getSkinnable()));
|
||||
} else {
|
||||
sliderValue.textProperty().bind(Bindings.createStringBinding(() -> {
|
||||
if (getSkinnable().getLabelFormatter() != null) {
|
||||
return getSkinnable().getLabelFormatter().toString(getSkinnable().getValue());
|
||||
} else {
|
||||
return String.valueOf(Math.round(getSkinnable().getValue()));
|
||||
}
|
||||
}, getSkinnable().valueProperty()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void layoutChildren(double x, double y, double w, double h) {
|
||||
super.layoutChildren(x, y, w, h);
|
||||
|
||||
if (timeline == null) {
|
||||
initAnimation(getSkinnable().getOrientation());
|
||||
}
|
||||
|
||||
double prefWidth = animatedThumb.prefWidth(-1);
|
||||
animatedThumb.resize(prefWidth, animatedThumb.prefHeight(prefWidth));
|
||||
|
||||
boolean horizontal = getSkinnable().getOrientation() == Orientation.HORIZONTAL;
|
||||
double width, height, layoutX, layoutY;
|
||||
if (horizontal) {
|
||||
width = thumb.getLayoutX() - snappedLeftInset();
|
||||
height = track.getHeight();
|
||||
layoutX = track.getLayoutX();
|
||||
layoutY = track.getLayoutY();
|
||||
animatedThumb.setLayoutX(thumb.getLayoutX() + thumb.getWidth() / 2 - animatedThumb.getWidth() / 2);
|
||||
} else {
|
||||
height = track.getLayoutBounds().getMaxY() + track.getLayoutY() - thumb.getLayoutY() - snappedBottomInset();
|
||||
width = track.getWidth();
|
||||
layoutX = track.getLayoutX();
|
||||
layoutY = thumb.getLayoutY();
|
||||
animatedThumb.setLayoutY(thumb.getLayoutY() + thumb.getHeight() / 2 - animatedThumb.getHeight() / 2);
|
||||
}
|
||||
|
||||
coloredTrack.resizeRelocate(layoutX, layoutY, width, height);
|
||||
mouseHandlerPane.resizeRelocate(x, y, w, h);
|
||||
}
|
||||
|
||||
private void initializeVariables() {
|
||||
shifting = 30 + thumb.getWidth();
|
||||
if (getSkinnable().getOrientation() != Orientation.HORIZONTAL) {
|
||||
horizontalRotation = -90;
|
||||
}
|
||||
if (((JFXSlider) getSkinnable()).getIndicatorPosition() != IndicatorPosition.LEFT) {
|
||||
indicatorRotation = 180;
|
||||
shifting = -shifting;
|
||||
}
|
||||
final double rotationAngle = 45;
|
||||
sliderValue.setRotate(rotationAngle + indicatorRotation + 3 * horizontalRotation);
|
||||
animatedThumb.setRotate(-rotationAngle + indicatorRotation + horizontalRotation);
|
||||
}
|
||||
|
||||
private void initListeners() {
|
||||
// delegate slider mouse events to track node
|
||||
mouseHandlerPane.setOnMousePressed(this::delegateToTrack);
|
||||
mouseHandlerPane.setOnMouseReleased(this::delegateToTrack);
|
||||
mouseHandlerPane.setOnMouseDragged(this::delegateToTrack);
|
||||
|
||||
// animate value node
|
||||
track.addEventHandler(MouseEvent.MOUSE_PRESSED, (event) -> {
|
||||
timeline.setRate(1);
|
||||
timeline.play();
|
||||
});
|
||||
track.addEventHandler(MouseEvent.MOUSE_RELEASED, (event) -> {
|
||||
timeline.setRate(-1);
|
||||
timeline.play();
|
||||
});
|
||||
thumb.addEventHandler(MouseEvent.MOUSE_PRESSED, (event) -> {
|
||||
timeline.setRate(1);
|
||||
timeline.play();
|
||||
});
|
||||
thumb.addEventHandler(MouseEvent.MOUSE_RELEASED, (event) -> {
|
||||
timeline.setRate(-1);
|
||||
timeline.play();
|
||||
});
|
||||
|
||||
refreshSliderValueBinding();
|
||||
updateValueStyleClass();
|
||||
|
||||
getSkinnable().valueProperty().addListener(observable -> updateValueStyleClass());
|
||||
}
|
||||
|
||||
private void delegateToTrack(MouseEvent event) {
|
||||
if (!event.isConsumed()) {
|
||||
event.consume();
|
||||
track.fireEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateValueStyleClass() {
|
||||
getSkinnable().pseudoClassStateChanged(MIN_VALUE, getSkinnable().getMin() == getSkinnable().getValue());
|
||||
getSkinnable().pseudoClassStateChanged(MAX_VALUE, getSkinnable().getMax() == getSkinnable().getValue());
|
||||
}
|
||||
|
||||
private void initAnimation(Orientation orientation) {
|
||||
initializeVariables();
|
||||
|
||||
double thumbPos, thumbNewPos;
|
||||
DoubleProperty layoutProperty;
|
||||
|
||||
if (orientation == Orientation.HORIZONTAL) {
|
||||
if (((JFXSlider) getSkinnable()).getIndicatorPosition() == IndicatorPosition.RIGHT) {
|
||||
thumbPos = thumb.getLayoutY() - thumb.getHeight();
|
||||
thumbNewPos = thumbPos - shifting;
|
||||
} else {
|
||||
double height = animatedThumb.prefHeight(animatedThumb.prefWidth(-1));
|
||||
thumbPos = thumb.getLayoutY() - height / 2;
|
||||
thumbNewPos = thumb.getLayoutY() - height - thumb.getHeight();
|
||||
}
|
||||
layoutProperty = animatedThumb.translateYProperty();
|
||||
} else {
|
||||
if (((JFXSlider) getSkinnable()).getIndicatorPosition() == IndicatorPosition.RIGHT) {
|
||||
thumbPos = thumb.getLayoutX() - thumb.getWidth();
|
||||
thumbNewPos = thumbPos - shifting;
|
||||
} else {
|
||||
double width = animatedThumb.prefWidth(-1);
|
||||
thumbPos = thumb.getLayoutX() - width / 2;
|
||||
thumbNewPos = thumb.getLayoutX() - width - thumb.getWidth();
|
||||
}
|
||||
layoutProperty = animatedThumb.translateXProperty();
|
||||
}
|
||||
|
||||
clearAnimation();
|
||||
|
||||
timeline = new Timeline(
|
||||
new KeyFrame(
|
||||
Duration.ZERO,
|
||||
new KeyValue(animatedThumb.scaleXProperty(), 0, Interpolator.EASE_BOTH),
|
||||
new KeyValue(animatedThumb.scaleYProperty(), 0, Interpolator.EASE_BOTH),
|
||||
new KeyValue(layoutProperty, thumbPos, Interpolator.EASE_BOTH)),
|
||||
new KeyFrame(
|
||||
Duration.seconds(0.2),
|
||||
new KeyValue(animatedThumb.scaleXProperty(), 1, Interpolator.EASE_BOTH),
|
||||
new KeyValue(animatedThumb.scaleYProperty(), 1, Interpolator.EASE_BOTH),
|
||||
new KeyValue(layoutProperty, thumbNewPos, Interpolator.EASE_BOTH)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
clearAnimation();
|
||||
}
|
||||
|
||||
private void clearAnimation() {
|
||||
if (timeline != null) {
|
||||
timeline.stop();
|
||||
timeline.getKeyFrames().clear();
|
||||
timeline = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,330 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.jfoenix.skins;
|
||||
|
||||
import com.jfoenix.controls.JFXSpinner;
|
||||
import com.jfoenix.utils.JFXNodeUtils;
|
||||
import com.jfoenix.utils.TreeShowingProperty;
|
||||
import javafx.animation.Interpolator;
|
||||
import javafx.animation.KeyFrame;
|
||||
import javafx.animation.KeyValue;
|
||||
import javafx.animation.Timeline;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.control.ProgressIndicator;
|
||||
import javafx.scene.control.SkinBase;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.paint.Paint;
|
||||
import javafx.scene.shape.Arc;
|
||||
import javafx.scene.shape.Rectangle;
|
||||
import javafx.scene.shape.StrokeLineCap;
|
||||
import javafx.scene.text.Font;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.util.Duration;
|
||||
|
||||
/// JFXSpinner material design skin
|
||||
///
|
||||
/// @author Shadi Shaheen & Gerard Moubarak
|
||||
/// @version 1.0
|
||||
/// @since 2017-09-25
|
||||
public class JFXSpinnerSkin extends SkinBase<JFXSpinner> {
|
||||
|
||||
private static final Color GREEN_COLOR = Color.valueOf("#0F9D58");
|
||||
private static final Color RED_COLOR = Color.valueOf("#db4437");
|
||||
private static final Color YELLOW_COLOR = Color.valueOf("#f4b400");
|
||||
private static final Color BLUE_COLOR = Color.valueOf("#4285f4");
|
||||
|
||||
private JFXSpinner control;
|
||||
private final TreeShowingProperty treeShowingProperty;
|
||||
private boolean isValid = false;
|
||||
|
||||
private Timeline timeline;
|
||||
private Arc arc;
|
||||
private Arc track;
|
||||
private final StackPane arcPane;
|
||||
private final Rectangle fillRect;
|
||||
private double arcLength = -1;
|
||||
private final Text text;
|
||||
|
||||
public JFXSpinnerSkin(JFXSpinner control) {
|
||||
super(control);
|
||||
|
||||
this.control = control;
|
||||
this.treeShowingProperty = new TreeShowingProperty(control);
|
||||
|
||||
arc = new Arc();
|
||||
arc.setManaged(false);
|
||||
arc.setStartAngle(0);
|
||||
arc.setLength(180);
|
||||
arc.getStyleClass().setAll("arc");
|
||||
arc.setFill(Color.TRANSPARENT);
|
||||
arc.setStrokeWidth(3);
|
||||
arc.setStrokeLineCap(StrokeLineCap.ROUND);
|
||||
|
||||
track = new Arc();
|
||||
track.setManaged(false);
|
||||
track.setStartAngle(0);
|
||||
track.setLength(360);
|
||||
track.setStrokeWidth(3);
|
||||
track.getStyleClass().setAll("track");
|
||||
track.setFill(Color.TRANSPARENT);
|
||||
|
||||
fillRect = new Rectangle();
|
||||
fillRect.setFill(Color.TRANSPARENT);
|
||||
text = new Text();
|
||||
text.setStyle("-fx-font-size:null");
|
||||
text.getStyleClass().setAll("text", "percentage");
|
||||
final Group group = new Group(fillRect, track, arc, text);
|
||||
group.setManaged(false);
|
||||
arcPane = new StackPane(group);
|
||||
arcPane.setPrefSize(50, 50);
|
||||
getChildren().setAll(arcPane);
|
||||
|
||||
// register listeners
|
||||
registerChangeListener(control.indeterminateProperty(), obs -> initialize());
|
||||
registerChangeListener(control.progressProperty(), obs -> updateProgress());
|
||||
registerChangeListener(treeShowingProperty, obs -> updateAnimation());
|
||||
registerChangeListener(control.sceneProperty(), obs -> updateAnimation());
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
if (getSkinnable().isIndeterminate()) {
|
||||
if (timeline == null) {
|
||||
createTransition();
|
||||
if (JFXNodeUtils.isTreeShowing(getSkinnable())) {
|
||||
timeline.play();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
clearAnimation();
|
||||
arc.setStartAngle(90);
|
||||
updateProgress();
|
||||
}
|
||||
}
|
||||
|
||||
private KeyFrame[] getKeyFrames(double angle, double duration, Paint color) {
|
||||
KeyFrame[] frames = new KeyFrame[4];
|
||||
frames[0] = new KeyFrame(Duration.seconds(duration),
|
||||
new KeyValue(arc.lengthProperty(), 5, Interpolator.LINEAR),
|
||||
new KeyValue(arc.startAngleProperty(),
|
||||
angle + 45 + control.getStartingAngle(),
|
||||
Interpolator.LINEAR));
|
||||
frames[1] = new KeyFrame(Duration.seconds(duration + 0.4),
|
||||
new KeyValue(arc.lengthProperty(), 250, Interpolator.LINEAR),
|
||||
new KeyValue(arc.startAngleProperty(),
|
||||
angle + 90 + control.getStartingAngle(),
|
||||
Interpolator.LINEAR));
|
||||
frames[2] = new KeyFrame(Duration.seconds(duration + 0.7),
|
||||
new KeyValue(arc.lengthProperty(), 250, Interpolator.LINEAR),
|
||||
new KeyValue(arc.startAngleProperty(),
|
||||
angle + 135 + control.getStartingAngle(),
|
||||
Interpolator.LINEAR));
|
||||
frames[3] = new KeyFrame(Duration.seconds(duration + 1.1),
|
||||
new KeyValue(arc.lengthProperty(), 5, Interpolator.LINEAR),
|
||||
new KeyValue(arc.startAngleProperty(),
|
||||
angle + 435 + control.getStartingAngle(),
|
||||
Interpolator.LINEAR),
|
||||
new KeyValue(arc.strokeProperty(), color, Interpolator.EASE_BOTH));
|
||||
return frames;
|
||||
}
|
||||
|
||||
private void pauseTimeline(boolean pause) {
|
||||
if (getSkinnable().isIndeterminate()) {
|
||||
if (timeline == null) {
|
||||
createTransition();
|
||||
}
|
||||
if (pause) {
|
||||
timeline.pause();
|
||||
} else {
|
||||
timeline.play();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAnimation() {
|
||||
final boolean isTreeShowing = treeShowingProperty.get();
|
||||
if (timeline != null) {
|
||||
pauseTimeline(!isTreeShowing);
|
||||
} else if (isTreeShowing) {
|
||||
createTransition();
|
||||
}
|
||||
}
|
||||
|
||||
private double computeSize() {
|
||||
return control.getRadius() * 2 + arc.getStrokeWidth() * 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double computeMaxHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
|
||||
if (Region.USE_COMPUTED_SIZE == control.getRadius()) {
|
||||
return super.computeMaxHeight(width, topInset, rightInset, bottomInset, leftInset);
|
||||
} else {
|
||||
return computeSize();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double computeMaxWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
|
||||
if (Region.USE_COMPUTED_SIZE == control.getRadius()) {
|
||||
return super.computeMaxWidth(height, topInset, rightInset, bottomInset, leftInset);
|
||||
} else {
|
||||
return computeSize();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
|
||||
if (Region.USE_COMPUTED_SIZE == control.getRadius()) {
|
||||
return arcPane.prefWidth(-1);
|
||||
} else {
|
||||
return computeSize();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
|
||||
if (Region.USE_COMPUTED_SIZE == control.getRadius()) {
|
||||
return arcPane.prefHeight(-1);
|
||||
} else {
|
||||
return computeSize();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void layoutChildren(double contentX, double contentY, double contentWidth, double contentHeight) {
|
||||
final double strokeWidth = arc.getStrokeWidth();
|
||||
double radius = control.getRadius();
|
||||
final double arcSize = snapSizeX(radius * 2 + strokeWidth);
|
||||
|
||||
arcPane.resizeRelocate((contentWidth - arcSize) / 2 + 1, (contentHeight - arcSize) / 2 + 1, arcSize, arcSize);
|
||||
updateArcLayout(radius, arcSize);
|
||||
|
||||
fillRect.setWidth(arcSize);
|
||||
fillRect.setHeight(arcSize);
|
||||
|
||||
if (!isValid) {
|
||||
initialize();
|
||||
isValid = true;
|
||||
}
|
||||
|
||||
if (!getSkinnable().isIndeterminate()) {
|
||||
arc.setLength(arcLength);
|
||||
if (text.isVisible()) {
|
||||
final double progress = control.getProgress();
|
||||
int intProgress = (int) Math.round(progress * 100.0);
|
||||
Font font = text.getFont();
|
||||
text.setFont(Font.font(font.getFamily(), radius / 1.7));
|
||||
text.setText((progress > 1 ? 100 : intProgress) + "%");
|
||||
text.relocate((arcSize - text.getLayoutBounds().getWidth()) / 2, (arcSize - text.getLayoutBounds().getHeight()) / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateArcLayout(double radius, double arcSize) {
|
||||
arc.setRadiusX(radius);
|
||||
arc.setRadiusY(radius);
|
||||
arc.setCenterX(arcSize / 2);
|
||||
arc.setCenterY(arcSize / 2);
|
||||
|
||||
track.setRadiusX(radius);
|
||||
track.setRadiusY(radius);
|
||||
track.setCenterX(arcSize / 2);
|
||||
track.setCenterY(arcSize / 2);
|
||||
track.setStrokeWidth(arc.getStrokeWidth());
|
||||
}
|
||||
|
||||
boolean wasIndeterminate = false;
|
||||
|
||||
protected void updateProgress() {
|
||||
final ProgressIndicator control = getSkinnable();
|
||||
final boolean isIndeterminate = control.isIndeterminate();
|
||||
if (!(isIndeterminate && wasIndeterminate)) {
|
||||
arcLength = -360 * control.getProgress();
|
||||
control.requestLayout();
|
||||
}
|
||||
wasIndeterminate = isIndeterminate;
|
||||
}
|
||||
|
||||
private void createTransition() {
|
||||
if (!getSkinnable().isIndeterminate()) return;
|
||||
final Paint initialColor = arc.getStroke();
|
||||
if (initialColor == null) {
|
||||
arc.setStroke(BLUE_COLOR);
|
||||
}
|
||||
|
||||
KeyFrame[] blueFrame = getKeyFrames(0, 0, initialColor == null ? BLUE_COLOR : initialColor);
|
||||
KeyFrame[] redFrame = getKeyFrames(450, 1.4, initialColor == null ? RED_COLOR : initialColor);
|
||||
KeyFrame[] yellowFrame = getKeyFrames(900, 2.8, initialColor == null ? YELLOW_COLOR : initialColor);
|
||||
KeyFrame[] greenFrame = getKeyFrames(1350, 4.2, initialColor == null ? GREEN_COLOR : initialColor);
|
||||
|
||||
KeyFrame endingFrame = new KeyFrame(Duration.seconds(5.6),
|
||||
new KeyValue(arc.lengthProperty(), 5, Interpolator.LINEAR),
|
||||
new KeyValue(arc.startAngleProperty(),
|
||||
1845 + control.getStartingAngle(),
|
||||
Interpolator.LINEAR));
|
||||
|
||||
if (timeline != null) {
|
||||
timeline.stop();
|
||||
timeline.getKeyFrames().clear();
|
||||
}
|
||||
timeline = new Timeline(blueFrame[0],
|
||||
blueFrame[1],
|
||||
blueFrame[2],
|
||||
blueFrame[3],
|
||||
redFrame[0],
|
||||
redFrame[1],
|
||||
redFrame[2],
|
||||
redFrame[3],
|
||||
yellowFrame[0],
|
||||
yellowFrame[1],
|
||||
yellowFrame[2],
|
||||
yellowFrame[3],
|
||||
greenFrame[0],
|
||||
greenFrame[1],
|
||||
greenFrame[2],
|
||||
greenFrame[3],
|
||||
endingFrame);
|
||||
timeline.setCycleCount(Timeline.INDEFINITE);
|
||||
timeline.setDelay(Duration.ZERO);
|
||||
timeline.playFromStart();
|
||||
}
|
||||
|
||||
private void clearAnimation() {
|
||||
if (timeline != null) {
|
||||
timeline.stop();
|
||||
timeline.getKeyFrames().clear();
|
||||
timeline = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
treeShowingProperty.dispose();
|
||||
clearAnimation();
|
||||
arc = null;
|
||||
track = null;
|
||||
control = null;
|
||||
}
|
||||
}
|
||||
@@ -19,25 +19,13 @@
|
||||
|
||||
package com.jfoenix.utils;
|
||||
|
||||
import javafx.beans.value.ObservableBooleanValue;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.Background;
|
||||
import javafx.scene.layout.BackgroundFill;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.paint.Paint;
|
||||
import javafx.stage.Window;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Locale;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static org.jackhuang.hmcl.util.logging.Logger.LOG;
|
||||
|
||||
/// @author Shadi Shaheen
|
||||
/// @version 1.0
|
||||
@@ -70,70 +58,6 @@ public final class JFXNodeUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private static final @NotNull Function<Node, ObservableBooleanValue> treeVisiblePropertyGetter = initTreeVisiblePropertyGetter();
|
||||
|
||||
private static @NotNull Function<Node, ObservableBooleanValue> initTreeVisiblePropertyGetter() {
|
||||
|
||||
MethodHandles.Lookup lookup;
|
||||
try {
|
||||
lookup = MethodHandles.privateLookupIn(Node.class, MethodHandles.lookup());
|
||||
} catch (IllegalAccessException e) {
|
||||
LOG.warning("Failed to get private lookup for Node", e);
|
||||
return JFXNodeUtils::defaultTreeVisibleProperty;
|
||||
}
|
||||
|
||||
try {
|
||||
Method treeVisiblePropertyMethod = Node.class.getDeclaredMethod("treeVisibleProperty");
|
||||
if (!ObservableBooleanValue.class.isAssignableFrom(treeVisiblePropertyMethod.getReturnType())) {
|
||||
LOG.warning("Node.treeVisibleProperty() does not return ObservableBooleanValue: " + treeVisiblePropertyMethod.getReturnType());
|
||||
return JFXNodeUtils::defaultTreeVisibleProperty;
|
||||
}
|
||||
|
||||
MethodHandle handle = lookup.unreflect(treeVisiblePropertyMethod)
|
||||
.asType(MethodType.methodType(ObservableBooleanValue.class, Node.class));
|
||||
return item -> {
|
||||
try {
|
||||
return (ObservableBooleanValue) handle.invokeExact((Node) item);
|
||||
} catch (RuntimeException | Error e) {
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
throw new AssertionError("Unreachable", e);
|
||||
}
|
||||
};
|
||||
} catch (Exception e) {
|
||||
LOG.warning("Failed to get method handle for Node.treeVisibleProperty()", e);
|
||||
return JFXNodeUtils::defaultTreeVisibleProperty;
|
||||
}
|
||||
}
|
||||
|
||||
/// If `Node.treeVisibleProperty()` does not exist, use `Node.visibleProperty()` as a fallback
|
||||
private static @NotNull ObservableBooleanValue defaultTreeVisibleProperty(Node item) {
|
||||
return item.visibleProperty();
|
||||
}
|
||||
|
||||
public static @NotNull ObservableBooleanValue treeVisibleProperty(Node item) {
|
||||
return treeVisiblePropertyGetter.apply(item);
|
||||
}
|
||||
|
||||
public static boolean isTreeVisible(Node item) {
|
||||
return treeVisibleProperty(item).getValue();
|
||||
}
|
||||
|
||||
public static boolean isTreeShowing(Node node) {
|
||||
if (node == null)
|
||||
return false;
|
||||
|
||||
Scene scene = node.getScene();
|
||||
if (scene == null)
|
||||
return false;
|
||||
|
||||
Window window = scene.getWindow();
|
||||
if (window == null || !window.isShowing())
|
||||
return false;
|
||||
|
||||
return isTreeVisible(node);
|
||||
}
|
||||
|
||||
private JFXNodeUtils() {
|
||||
}
|
||||
|
||||
|
||||
@@ -1,143 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code 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
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.jfoenix.utils;
|
||||
|
||||
import javafx.beans.property.ReadOnlyBooleanPropertyBase;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableBooleanValue;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Window;
|
||||
|
||||
/**
|
||||
* Used to observe changes in tree showing status for a {@link Node}. For a Node's tree to be showing
|
||||
* it must be visible, its ancestors must be visible, the node must be part of a {@link Scene} and
|
||||
* the scene must have a {@link Window} which is currently showing.<p>
|
||||
*
|
||||
* This class provides the exact same functionality as {@link JFXNodeUtils#isTreeShowing(Node)} in
|
||||
* an observable form.
|
||||
*/
|
||||
public class TreeShowingProperty extends ReadOnlyBooleanPropertyBase {
|
||||
private final ChangeListener<Boolean> windowShowingChangedListener = (obs, old, current) -> updateTreeShowing();
|
||||
private final ChangeListener<Window> sceneWindowChangedListener = (obs, old, current) -> windowChanged(old, current);
|
||||
private final ChangeListener<Scene> nodeSceneChangedListener = (obs, old, current) -> sceneChanged(old, current);
|
||||
|
||||
private final Node node;
|
||||
private final ObservableBooleanValue treeVisibleProperty;
|
||||
|
||||
private boolean valid;
|
||||
private boolean treeShowing;
|
||||
|
||||
/**
|
||||
* Constructs a new instance.
|
||||
*
|
||||
* @param node a {@link Node} for which the tree showing status should be observed, cannot be null
|
||||
*/
|
||||
public TreeShowingProperty(Node node) {
|
||||
this.node = node;
|
||||
this.treeVisibleProperty = JFXNodeUtils.treeVisibleProperty(node);
|
||||
|
||||
this.node.sceneProperty().addListener(nodeSceneChangedListener);
|
||||
this.treeVisibleProperty.addListener(windowShowingChangedListener);
|
||||
|
||||
sceneChanged(null, node.getScene());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getBean() {
|
||||
return node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "treeShowing";
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans up any listeners that this class may have registered on the {@link Node}
|
||||
* that was supplied at construction.
|
||||
*/
|
||||
public void dispose() {
|
||||
node.sceneProperty().removeListener(nodeSceneChangedListener);
|
||||
|
||||
if (treeVisibleProperty != null)
|
||||
treeVisibleProperty.removeListener(windowShowingChangedListener);
|
||||
|
||||
valid = false; // prevents unregistration from triggering an invalidation notification
|
||||
sceneChanged(node.getScene(), null);
|
||||
}
|
||||
|
||||
protected void invalidate() {
|
||||
if (valid) {
|
||||
valid = false;
|
||||
fireValueChangedEvent();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean get() {
|
||||
if (!valid) {
|
||||
updateTreeShowing();
|
||||
valid = true;
|
||||
}
|
||||
|
||||
return treeShowing;
|
||||
}
|
||||
|
||||
private void sceneChanged(Scene oldScene, Scene newScene) {
|
||||
if (oldScene != null) {
|
||||
oldScene.windowProperty().removeListener(sceneWindowChangedListener);
|
||||
}
|
||||
if (newScene != null) {
|
||||
newScene.windowProperty().addListener(sceneWindowChangedListener);
|
||||
}
|
||||
|
||||
windowChanged(
|
||||
oldScene == null ? null : oldScene.getWindow(),
|
||||
newScene == null ? null : newScene.getWindow()
|
||||
);
|
||||
}
|
||||
|
||||
private void windowChanged(Window oldWindow, Window newWindow) {
|
||||
if (oldWindow != null) {
|
||||
oldWindow.showingProperty().removeListener(windowShowingChangedListener);
|
||||
}
|
||||
if (newWindow != null) {
|
||||
newWindow.showingProperty().addListener(windowShowingChangedListener);
|
||||
}
|
||||
|
||||
updateTreeShowing();
|
||||
}
|
||||
|
||||
private void updateTreeShowing() {
|
||||
boolean newValue = JFXNodeUtils.isTreeShowing(node);
|
||||
|
||||
if (newValue != treeShowing) {
|
||||
treeShowing = newValue;
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -200,6 +200,9 @@ public final class EntryPoint {
|
||||
} catch (SelfDependencyPatcher.PatchException e) {
|
||||
LOG.error("Unable to patch JVM", e);
|
||||
showErrorAndExit(i18n("fatal.javafx.missing"));
|
||||
} catch (SelfDependencyPatcher.IncompatibleVersionException e) {
|
||||
LOG.error("Unable to patch JVM", e);
|
||||
showErrorAndExit(i18n("fatal.javafx.incompatible"));
|
||||
} catch (CancellationException e) {
|
||||
LOG.error("User cancels downloading JavaFX", e);
|
||||
exit(0);
|
||||
|
||||
@@ -249,11 +249,11 @@ public final class LauncherHelper {
|
||||
i18n("message.doing"),
|
||||
() -> launchingLatch.getCount() == 0, 6.95
|
||||
).withStage("launch.state.waiting_launching"))
|
||||
.withStagesHints(
|
||||
new Task.StagesHint("launch.state.java"),
|
||||
new Task.StagesHint("launch.state.dependencies", List.of("hmcl.install.assets", "hmcl.install.libraries", "hmcl.modpack.download")),
|
||||
new Task.StagesHint("launch.state.logging_in"),
|
||||
new Task.StagesHint("launch.state.waiting_launching"))
|
||||
.withStagesHint(Lang.immutableListOf(
|
||||
"launch.state.java",
|
||||
"launch.state.dependencies",
|
||||
"launch.state.logging_in",
|
||||
"launch.state.waiting_launching"))
|
||||
.executor();
|
||||
launchingStepsPane.setExecutor(executor, false);
|
||||
executor.addTaskListener(new TaskListener() {
|
||||
|
||||
@@ -167,7 +167,7 @@ public final class ModpackHelper {
|
||||
|
||||
return new ServerModpackRemoteInstallTask(profile.getDependency(), manifest, name)
|
||||
.whenComplete(Schedulers.defaultScheduler(), success, failure)
|
||||
.withStagesHints("hmcl.modpack", "hmcl.modpack.download");
|
||||
.withStagesHint(Arrays.asList("hmcl.modpack", "hmcl.modpack.download"));
|
||||
}
|
||||
|
||||
public static boolean isExternalGameNameConflicts(String name) {
|
||||
@@ -211,24 +211,23 @@ public final class ModpackHelper {
|
||||
return modpack.getInstallTask(profile.getDependency(), zipFile, name, iconUrl)
|
||||
.whenComplete(Schedulers.defaultScheduler(), success, failure)
|
||||
.thenComposeAsync(createMultiMCPostInstallTask(profile, (MultiMCInstanceConfiguration) modpack.getManifest(), name))
|
||||
.withStagesHints("hmcl.modpack", "hmcl.modpack.download");
|
||||
.withStagesHint(List.of("hmcl.modpack", "hmcl.modpack.download"));
|
||||
else if (modpack.getManifest() instanceof McbbsModpackManifest)
|
||||
return modpack.getInstallTask(profile.getDependency(), zipFile, name, iconUrl)
|
||||
.whenComplete(Schedulers.defaultScheduler(), success, failure)
|
||||
.thenComposeAsync(createMcbbsPostInstallTask(profile, (McbbsModpackManifest) modpack.getManifest(), name))
|
||||
.withStagesHints("hmcl.modpack", "hmcl.modpack.download");
|
||||
.withStagesHint(List.of("hmcl.modpack", "hmcl.modpack.download"));
|
||||
else
|
||||
return modpack.getInstallTask(profile.getDependency(), zipFile, name, iconUrl)
|
||||
.whenComplete(Schedulers.javafx(), success, failure)
|
||||
.withStagesHints("hmcl.modpack", "hmcl.modpack.download");
|
||||
.withStagesHint(List.of("hmcl.modpack", "hmcl.modpack.download"));
|
||||
}
|
||||
|
||||
public static Task<Void> getUpdateTask(Profile profile, ServerModpackManifest manifest, Charset charset, String name, ModpackConfiguration<?> configuration) throws UnsupportedModpackException {
|
||||
switch (configuration.getType()) {
|
||||
case ServerModpackRemoteInstallTask.MODPACK_TYPE:
|
||||
return new ModpackUpdateTask(profile.getRepository(), name, new ServerModpackRemoteInstallTask(profile.getDependency(), manifest, name))
|
||||
.thenComposeAsync(profile.getRepository().refreshVersionsAsync())
|
||||
.withStagesHints("hmcl.modpack", "hmcl.modpack.download");
|
||||
.withStagesHint(Arrays.asList("hmcl.modpack", "hmcl.modpack.download"));
|
||||
default:
|
||||
throw new UnsupportedModpackException();
|
||||
}
|
||||
@@ -242,11 +241,9 @@ public final class ModpackHelper {
|
||||
}
|
||||
if (modpack.getManifest() instanceof MultiMCInstanceConfiguration)
|
||||
return provider.createUpdateTask(profile.getDependency(), name, zipFile, modpack)
|
||||
.thenComposeAsync(() -> createMultiMCPostUpdateTask(profile, (MultiMCInstanceConfiguration) modpack.getManifest(), name))
|
||||
.thenComposeAsync(profile.getRepository().refreshVersionsAsync());
|
||||
.thenComposeAsync(() -> createMultiMCPostUpdateTask(profile, (MultiMCInstanceConfiguration) modpack.getManifest(), name));
|
||||
else
|
||||
return provider.createUpdateTask(profile.getDependency(), name, zipFile, modpack)
|
||||
.thenComposeAsync(profile.getRepository().refreshVersionsAsync());
|
||||
return provider.createUpdateTask(profile.getDependency(), name, zipFile, modpack);
|
||||
}
|
||||
|
||||
public static void toVersionSetting(MultiMCInstanceConfiguration c, VersionSetting vs) {
|
||||
|
||||
@@ -20,7 +20,6 @@ package org.jackhuang.hmcl.ui;
|
||||
import com.jfoenix.controls.*;
|
||||
import javafx.animation.Animation;
|
||||
import javafx.animation.Interpolator;
|
||||
import javafx.animation.PauseTransition;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.InvalidationListener;
|
||||
import javafx.beans.Observable;
|
||||
@@ -38,6 +37,7 @@ import javafx.event.EventDispatcher;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.event.EventType;
|
||||
import javafx.geometry.Bounds;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.geometry.Rectangle2D;
|
||||
import javafx.scene.Cursor;
|
||||
import javafx.scene.Node;
|
||||
@@ -51,6 +51,7 @@ import javafx.scene.input.*;
|
||||
import javafx.scene.layout.ColumnConstraints;
|
||||
import javafx.scene.layout.Priority;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.paint.Paint;
|
||||
import javafx.scene.shape.Rectangle;
|
||||
@@ -67,7 +68,6 @@ import org.jackhuang.hmcl.task.CacheFileTask;
|
||||
import org.jackhuang.hmcl.task.Schedulers;
|
||||
import org.jackhuang.hmcl.task.Task;
|
||||
import org.jackhuang.hmcl.ui.animation.AnimationUtils;
|
||||
import org.jackhuang.hmcl.ui.animation.Motion;
|
||||
import org.jackhuang.hmcl.ui.construct.IconedMenuItem;
|
||||
import org.jackhuang.hmcl.ui.construct.MenuSeparator;
|
||||
import org.jackhuang.hmcl.ui.construct.PopupMenu;
|
||||
@@ -417,6 +417,14 @@ public final class FXUtils {
|
||||
return region.getMaxHeight();
|
||||
}
|
||||
|
||||
public static Node limitingSize(Node node, double width, double height) {
|
||||
StackPane pane = new StackPane(node);
|
||||
pane.setAlignment(Pos.CENTER);
|
||||
FXUtils.setLimitWidth(pane, width);
|
||||
FXUtils.setLimitHeight(pane, height);
|
||||
return pane;
|
||||
}
|
||||
|
||||
public static void limitCellWidth(ListView<?> listView, ListCell<?> cell) {
|
||||
ReadOnlyDoubleProperty widthProperty;
|
||||
|
||||
@@ -1283,30 +1291,6 @@ public final class FXUtils {
|
||||
return button;
|
||||
}
|
||||
|
||||
public static JFXButton newToggleButton4(SVG icon, int size) {
|
||||
JFXButton button = new JFXButton();
|
||||
button.getStyleClass().add("toggle-icon4");
|
||||
button.setGraphic(icon.createIcon(size));
|
||||
return button;
|
||||
}
|
||||
|
||||
public static void setOnActionWithCooldown(ButtonBase button, Runnable action) {
|
||||
setOnActionWithCooldown(button, action, Motion.SHORT4);
|
||||
}
|
||||
|
||||
public static void setOnActionWithCooldown(ButtonBase button, Runnable action, Duration cooldown) {
|
||||
button.setOnAction(e -> {
|
||||
button.setDisable(true);
|
||||
|
||||
var pause = new PauseTransition(cooldown);
|
||||
pause.setOnFinished(event -> button.setDisable(false));
|
||||
pause.play();
|
||||
|
||||
action.run();
|
||||
e.consume();
|
||||
});
|
||||
}
|
||||
|
||||
public static Label newSafeTruncatedLabel() {
|
||||
Label label = new Label();
|
||||
label.setTextOverrun(OverrunStyle.CENTER_WORD_ELLIPSIS);
|
||||
|
||||
@@ -28,15 +28,16 @@ import javafx.css.PseudoClass;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Cursor;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Control;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.Skin;
|
||||
import javafx.scene.control.SkinBase;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.input.MouseButton;
|
||||
import javafx.scene.layout.*;
|
||||
import org.jackhuang.hmcl.download.LibraryAnalyzer;
|
||||
import org.jackhuang.hmcl.setting.VersionIconType;
|
||||
import org.jackhuang.hmcl.ui.construct.ImageContainer;
|
||||
import org.jackhuang.hmcl.ui.construct.RipplerContainer;
|
||||
import org.jackhuang.hmcl.util.i18n.I18n;
|
||||
import org.jackhuang.hmcl.util.versioning.GameVersionNumber;
|
||||
@@ -294,14 +295,14 @@ public class InstallerItem extends Control {
|
||||
paneWrapper.pseudoClassStateChanged(CARD, control.style == Style.CARD);
|
||||
|
||||
if (control.iconType != null) {
|
||||
var imageContainer = new ImageContainer(32);
|
||||
imageContainer.setImage(control.iconType.getIcon());
|
||||
imageContainer.setMouseTransparent(true);
|
||||
imageContainer.getStyleClass().add("installer-item-image");
|
||||
pane.getChildren().add(imageContainer);
|
||||
ImageView view = new ImageView(control.iconType.getIcon());
|
||||
Node node = FXUtils.limitingSize(view, 32, 32);
|
||||
node.setMouseTransparent(true);
|
||||
node.getStyleClass().add("installer-item-image");
|
||||
pane.getChildren().add(node);
|
||||
|
||||
if (control.style == Style.CARD) {
|
||||
VBox.setMargin(imageContainer, new Insets(8, 0, 16, 0));
|
||||
VBox.setMargin(node, new Insets(8, 0, 16, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,7 +348,9 @@ public class InstallerItem extends Control {
|
||||
buttonsContainer.setAlignment(Pos.CENTER);
|
||||
pane.getChildren().add(buttonsContainer);
|
||||
|
||||
JFXButton removeButton = FXUtils.newToggleButton4(SVG.CLOSE);
|
||||
JFXButton removeButton = new JFXButton();
|
||||
removeButton.setGraphic(SVG.CLOSE.createIcon());
|
||||
removeButton.getStyleClass().add("toggle-icon4");
|
||||
if (control.id.equals(MINECRAFT.getPatchId())) {
|
||||
removeButton.setVisible(false);
|
||||
} else {
|
||||
|
||||
@@ -17,7 +17,10 @@
|
||||
*/
|
||||
package org.jackhuang.hmcl.ui;
|
||||
|
||||
import com.jfoenix.controls.*;
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import com.jfoenix.controls.JFXCheckBox;
|
||||
import com.jfoenix.controls.JFXComboBox;
|
||||
import com.jfoenix.controls.JFXListView;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.InvalidationListener;
|
||||
import javafx.beans.binding.Bindings;
|
||||
@@ -40,12 +43,8 @@ import org.jackhuang.hmcl.theme.Themes;
|
||||
import org.jackhuang.hmcl.ui.construct.MessageDialogPane;
|
||||
import org.jackhuang.hmcl.ui.construct.NoneMultipleSelectionModel;
|
||||
import org.jackhuang.hmcl.ui.construct.SpinnerPane;
|
||||
import org.jackhuang.hmcl.util.CircularArrayList;
|
||||
import org.jackhuang.hmcl.util.Lang;
|
||||
import org.jackhuang.hmcl.util.Log4jLevel;
|
||||
import org.jackhuang.hmcl.util.StringUtils;
|
||||
import org.jackhuang.hmcl.util.platform.ManagedProcess;
|
||||
import org.jackhuang.hmcl.util.platform.SystemUtils;
|
||||
import org.jackhuang.hmcl.util.*;
|
||||
import org.jackhuang.hmcl.util.platform.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
@@ -258,7 +257,6 @@ public final class LogWindow extends Stage {
|
||||
private static final PseudoClass SELECTED = PseudoClass.getPseudoClass("selected");
|
||||
|
||||
private final Set<ListCell<Log>> selected = new HashSet<>();
|
||||
private final JFXSnackbar snackbar = new JFXSnackbar();
|
||||
|
||||
LogWindowSkin(LogWindowImpl control) {
|
||||
super(control);
|
||||
@@ -267,7 +265,7 @@ public final class LogWindow extends Stage {
|
||||
vbox.setPadding(new Insets(3, 0, 3, 0));
|
||||
getSkinnable().stackPane.getChildren().setAll(vbox);
|
||||
getChildren().setAll(getSkinnable().stackPane);
|
||||
snackbar.registerSnackbarContainer(getSkinnable().stackPane);
|
||||
|
||||
|
||||
{
|
||||
BorderPane borderPane = new BorderPane();
|
||||
@@ -383,8 +381,7 @@ public final class LogWindow extends Stage {
|
||||
}
|
||||
}
|
||||
|
||||
FXUtils.copyText(stringBuilder.toString(), null);
|
||||
snackbar.fireEvent(new JFXSnackbar.SnackbarEvent(new JFXSnackbarLayout(i18n("message.copied"))));
|
||||
FXUtils.copyText(stringBuilder.toString());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -415,7 +412,7 @@ public final class LogWindow extends Stage {
|
||||
if (SystemUtils.supportJVMAttachment()) {
|
||||
exportDumpButton.setOnAction(e -> getSkinnable().onExportDump(exportDumpPane));
|
||||
} else {
|
||||
FXUtils.installFastTooltip(exportDumpPane, i18n("logwindow.export_dump.no_dependency"));
|
||||
exportDumpButton.setTooltip(new Tooltip(i18n("logwindow.export_dump.no_dependency")));
|
||||
exportDumpButton.setDisable(true);
|
||||
}
|
||||
exportDumpPane.setContent(exportDumpButton);
|
||||
|
||||
@@ -125,7 +125,7 @@ public final class AccountListItemSkin extends SkinBase<AccountListItem> {
|
||||
spinnerMove.setContent(btnMove);
|
||||
right.getChildren().add(spinnerMove);
|
||||
|
||||
JFXButton btnRefresh = FXUtils.newToggleButton4(SVG.REFRESH);
|
||||
JFXButton btnRefresh = new JFXButton();
|
||||
SpinnerPane spinnerRefresh = new SpinnerPane();
|
||||
spinnerRefresh.getStyleClass().setAll("small-spinner-pane");
|
||||
if (skinnable.getAccount() instanceof MicrosoftAccount && Accounts.OAUTH_CALLBACK.getClientId().isEmpty()) {
|
||||
@@ -144,11 +144,13 @@ public final class AccountListItemSkin extends SkinBase<AccountListItem> {
|
||||
})
|
||||
.start();
|
||||
});
|
||||
btnRefresh.getStyleClass().add("toggle-icon4");
|
||||
btnRefresh.setGraphic(SVG.REFRESH.createIcon());
|
||||
FXUtils.installFastTooltip(btnRefresh, i18n("button.refresh"));
|
||||
spinnerRefresh.setContent(btnRefresh);
|
||||
right.getChildren().add(spinnerRefresh);
|
||||
|
||||
JFXButton btnUpload = FXUtils.newToggleButton4(SVG.CHECKROOM);
|
||||
JFXButton btnUpload = new JFXButton();
|
||||
SpinnerPane spinnerUpload = new SpinnerPane();
|
||||
btnUpload.setOnAction(e -> {
|
||||
Task<?> uploadTask = skinnable.uploadSkin();
|
||||
@@ -159,23 +161,29 @@ public final class AccountListItemSkin extends SkinBase<AccountListItem> {
|
||||
.start();
|
||||
}
|
||||
});
|
||||
btnUpload.getStyleClass().add("toggle-icon4");
|
||||
btnUpload.setGraphic(SVG.CHECKROOM.createIcon());
|
||||
FXUtils.installFastTooltip(btnUpload, i18n("account.skin.upload"));
|
||||
btnUpload.disableProperty().bind(Bindings.not(skinnable.canUploadSkin()));
|
||||
spinnerUpload.setContent(btnUpload);
|
||||
spinnerUpload.getStyleClass().add("small-spinner-pane");
|
||||
right.getChildren().add(spinnerUpload);
|
||||
|
||||
JFXButton btnCopyUUID = FXUtils.newToggleButton4(SVG.CONTENT_COPY);
|
||||
JFXButton btnCopyUUID = new JFXButton();
|
||||
SpinnerPane spinnerCopyUUID = new SpinnerPane();
|
||||
spinnerCopyUUID.getStyleClass().add("small-spinner-pane");
|
||||
btnUpload.getStyleClass().add("toggle-icon4");
|
||||
btnCopyUUID.setOnAction(e -> FXUtils.copyText(skinnable.getAccount().getUUID().toString()));
|
||||
btnCopyUUID.setGraphic(SVG.CONTENT_COPY.createIcon());
|
||||
FXUtils.installFastTooltip(btnCopyUUID, i18n("account.copy_uuid"));
|
||||
spinnerCopyUUID.setContent(btnCopyUUID);
|
||||
right.getChildren().add(spinnerCopyUUID);
|
||||
|
||||
JFXButton btnRemove = FXUtils.newToggleButton4(SVG.DELETE);
|
||||
JFXButton btnRemove = new JFXButton();
|
||||
btnRemove.setOnAction(e -> Controllers.confirm(i18n("button.remove.confirm"), i18n("button.remove"), skinnable::remove, null));
|
||||
btnRemove.getStyleClass().add("toggle-icon4");
|
||||
BorderPane.setAlignment(btnRemove, Pos.CENTER);
|
||||
btnRemove.setGraphic(SVG.DELETE.createIcon());
|
||||
FXUtils.installFastTooltip(btnRemove, i18n("button.delete"));
|
||||
right.getChildren().add(btnRemove);
|
||||
root.setRight(right);
|
||||
|
||||
@@ -399,7 +399,9 @@ public class CreateAccountPane extends JFXDialogLayout implements DialogAware {
|
||||
});
|
||||
linksContainer.setMinWidth(USE_PREF_SIZE);
|
||||
|
||||
JFXButton btnAddServer = FXUtils.newToggleButton4(SVG.ADD, 20);
|
||||
JFXButton btnAddServer = new JFXButton();
|
||||
btnAddServer.setGraphic(SVG.ADD.createIcon(20));
|
||||
btnAddServer.getStyleClass().add("toggle-icon4");
|
||||
btnAddServer.setOnAction(e -> {
|
||||
Controllers.dialog(new AddAuthlibInjectorServerPane());
|
||||
});
|
||||
@@ -564,7 +566,7 @@ public class CreateAccountPane extends JFXDialogLayout implements DialogAware {
|
||||
}
|
||||
}
|
||||
|
||||
public static class DialogCharacterSelector extends JFXDialogLayout implements CharacterSelector {
|
||||
private static class DialogCharacterSelector extends BorderPane implements CharacterSelector {
|
||||
|
||||
private final AdvancedListBox listBox = new AdvancedListBox();
|
||||
private final JFXButton cancel = new JFXButton();
|
||||
@@ -576,17 +578,17 @@ public class CreateAccountPane extends JFXDialogLayout implements DialogAware {
|
||||
setStyle("-fx-padding: 8px;");
|
||||
|
||||
cancel.setText(i18n("button.cancel"));
|
||||
StackPane.setAlignment(cancel, Pos.BOTTOM_RIGHT);
|
||||
cancel.setOnAction(e -> latch.countDown());
|
||||
cancel.getStyleClass().add("dialog-cancel");
|
||||
|
||||
listBox.startCategory(i18n("account.choose").toUpperCase(Locale.ROOT));
|
||||
|
||||
setBody(listBox);
|
||||
setCenter(listBox);
|
||||
|
||||
HBox hbox = new HBox();
|
||||
hbox.setAlignment(Pos.CENTER_RIGHT);
|
||||
hbox.getChildren().add(cancel);
|
||||
setActions(hbox);
|
||||
setBottom(hbox);
|
||||
|
||||
onEscPressed(this, cancel::fire);
|
||||
}
|
||||
|
||||
@@ -1,20 +1,3 @@
|
||||
/*
|
||||
* 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.account;
|
||||
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.jackhuang.hmcl.ui.construct;
|
||||
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import javafx.beans.property.*;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
@@ -84,11 +85,13 @@ public class AdvancedListItem extends Control {
|
||||
}
|
||||
|
||||
public void setRightAction(SVG icon, Runnable action) {
|
||||
var button = FXUtils.newToggleButton4(icon, 14);
|
||||
var button = new JFXButton();
|
||||
button.setOnAction(e -> {
|
||||
action.run();
|
||||
e.consume();
|
||||
});
|
||||
button.getStyleClass().add("toggle-icon4");
|
||||
button.setGraphic(icon.createIcon(14));
|
||||
setAlignment(button, Pos.CENTER);
|
||||
setRightGraphic(button);
|
||||
}
|
||||
|
||||
@@ -80,7 +80,8 @@ public class FileSelector extends HBox {
|
||||
JFXTextField customField = new JFXTextField();
|
||||
FXUtils.bindString(customField, valueProperty());
|
||||
|
||||
JFXButton selectButton = FXUtils.newToggleButton4(SVG.FOLDER_OPEN, 15);
|
||||
JFXButton selectButton = new JFXButton();
|
||||
selectButton.setGraphic(SVG.FOLDER_OPEN.createIcon(15));
|
||||
selectButton.setOnAction(e -> {
|
||||
if (directory) {
|
||||
DirectoryChooser chooser = new DirectoryChooser();
|
||||
|
||||
@@ -129,12 +129,12 @@ public class FloatScrollBarSkin implements Skin<ScrollBar> {
|
||||
track.heightProperty().unbind();
|
||||
|
||||
if (scrollBar.getOrientation() == Orientation.HORIZONTAL) {
|
||||
track.relocate(0, -8);
|
||||
track.relocate(0, -5);
|
||||
track.widthProperty().bind(scrollBar.widthProperty());
|
||||
track.setHeight(8);
|
||||
track.setHeight(5);
|
||||
} else {
|
||||
track.relocate(-8, 0);
|
||||
track.setWidth(8);
|
||||
track.relocate(-5, 0);
|
||||
track.setWidth(5);
|
||||
track.heightProperty().bind(scrollBar.heightProperty());
|
||||
}
|
||||
|
||||
@@ -144,13 +144,13 @@ public class FloatScrollBarSkin implements Skin<ScrollBar> {
|
||||
thumb.heightProperty().unbind();
|
||||
|
||||
if (scrollBar.getOrientation() == Orientation.HORIZONTAL) {
|
||||
thumb.relocate(0, -8);
|
||||
thumb.relocate(0, -5);
|
||||
thumb.widthProperty().bind(Bindings.max(20, scrollBar.visibleAmountProperty().divide(range).multiply(scrollBar.widthProperty())));
|
||||
thumb.setHeight(8);
|
||||
thumb.setHeight(5);
|
||||
thumb.xProperty().bind(Bindings.subtract(scrollBar.widthProperty(), thumb.widthProperty()).multiply(position));
|
||||
} else {
|
||||
thumb.relocate(-8, 0);
|
||||
thumb.setWidth(8);
|
||||
thumb.relocate(-5, 0);
|
||||
thumb.setWidth(5);
|
||||
thumb.heightProperty().bind(Bindings.max(20, scrollBar.visibleAmountProperty().divide(range).multiply(scrollBar.heightProperty())));
|
||||
thumb.yProperty().bind(Bindings.subtract(scrollBar.heightProperty(), thumb.heightProperty()).multiply(position));
|
||||
}
|
||||
@@ -162,7 +162,7 @@ public class FloatScrollBarSkin implements Skin<ScrollBar> {
|
||||
return Double.MAX_VALUE;
|
||||
}
|
||||
|
||||
return 8;
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -171,7 +171,7 @@ public class FloatScrollBarSkin implements Skin<ScrollBar> {
|
||||
return Double.MAX_VALUE;
|
||||
}
|
||||
|
||||
return 8;
|
||||
return 5;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,163 +0,0 @@
|
||||
/*
|
||||
* 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.construct;
|
||||
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.css.CssMetaData;
|
||||
import javafx.css.Styleable;
|
||||
import javafx.css.StyleableDoubleProperty;
|
||||
import javafx.css.StyleableProperty;
|
||||
import javafx.css.converter.SizeConverter;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.shape.Rectangle;
|
||||
import org.jackhuang.hmcl.ui.FXUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/// A custom ImageView with fixed size and corner radius support.
|
||||
public class ImageContainer extends StackPane {
|
||||
|
||||
private static final String DEFAULT_STYLE_CLASS = "image-container";
|
||||
|
||||
private final ImageView imageView = new ImageView();
|
||||
private final Rectangle clip = new Rectangle();
|
||||
|
||||
public ImageContainer(double size) {
|
||||
this(size, size);
|
||||
}
|
||||
|
||||
public ImageContainer(double width, double height) {
|
||||
this.getStyleClass().add(DEFAULT_STYLE_CLASS);
|
||||
|
||||
FXUtils.setLimitWidth(this, width);
|
||||
FXUtils.setLimitHeight(this, height);
|
||||
|
||||
imageView.setPreserveRatio(true);
|
||||
FXUtils.limitSize(imageView, width, height);
|
||||
StackPane.setAlignment(imageView, Pos.CENTER);
|
||||
|
||||
clip.setWidth(width);
|
||||
clip.setHeight(height);
|
||||
updateCornerRadius(getCornerRadius());
|
||||
this.setClip(clip);
|
||||
|
||||
this.getChildren().setAll(imageView);
|
||||
}
|
||||
|
||||
private void updateCornerRadius(double radius) {
|
||||
clip.setArcWidth(radius);
|
||||
clip.setArcHeight(radius);
|
||||
}
|
||||
|
||||
private static final double DEFAULT_CORNER_RADIUS = 6.0;
|
||||
|
||||
private StyleableDoubleProperty cornerRadius;
|
||||
|
||||
public StyleableDoubleProperty cornerRadiusProperty() {
|
||||
if (this.cornerRadius == null) {
|
||||
cornerRadius = new StyleableDoubleProperty() {
|
||||
@Override
|
||||
public Object getBean() {
|
||||
return ImageContainer.this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "cornerRadius";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CssMetaData<? extends Styleable, Number> getCssMetaData() {
|
||||
return StyleableProperties.CORNER_RADIUS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void invalidated() {
|
||||
updateCornerRadius(get());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return cornerRadius;
|
||||
}
|
||||
|
||||
public double getCornerRadius() {
|
||||
return cornerRadius == null ? DEFAULT_CORNER_RADIUS : cornerRadius.get();
|
||||
}
|
||||
|
||||
public void setCornerRadius(double radius) {
|
||||
cornerRadiusProperty().set(radius);
|
||||
}
|
||||
|
||||
public ObjectProperty<Image> imageProperty() {
|
||||
return imageView.imageProperty();
|
||||
}
|
||||
|
||||
public Image getImage() {
|
||||
return imageView.getImage();
|
||||
}
|
||||
|
||||
public void setImage(Image image) {
|
||||
imageView.setImage(image);
|
||||
}
|
||||
|
||||
public BooleanProperty smoothProperty() {
|
||||
return imageView.smoothProperty();
|
||||
}
|
||||
|
||||
public boolean isSmooth() {
|
||||
return imageView.isSmooth();
|
||||
}
|
||||
|
||||
public void setSmooth(boolean smooth) {
|
||||
imageView.setSmooth(smooth);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CssMetaData<? extends Styleable, ?>> getCssMetaData() {
|
||||
return StyleableProperties.STYLEABLES;
|
||||
}
|
||||
|
||||
private static final class StyleableProperties {
|
||||
private static final CssMetaData<ImageContainer, Number> CORNER_RADIUS =
|
||||
new CssMetaData<>("-jfx-corner-radius", SizeConverter.getInstance(), DEFAULT_CORNER_RADIUS) {
|
||||
@Override
|
||||
public boolean isSettable(ImageContainer control) {
|
||||
return control.cornerRadius == null || !control.cornerRadius.isBound();
|
||||
}
|
||||
|
||||
@Override
|
||||
public StyleableProperty<Number> getStyleableProperty(ImageContainer control) {
|
||||
return control.cornerRadiusProperty();
|
||||
}
|
||||
};
|
||||
|
||||
private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES;
|
||||
|
||||
static {
|
||||
var styleables = new ArrayList<>(StackPane.getClassCssMetaData());
|
||||
styleables.add(CORNER_RADIUS);
|
||||
STYLEABLES = List.copyOf(styleables);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import javafx.event.EventHandler;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
@@ -39,7 +40,7 @@ import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
||||
@DefaultProperty("image")
|
||||
public final class ImagePickerItem extends BorderPane {
|
||||
|
||||
private final ImageContainer imageContainer;
|
||||
private final ImageView imageView;
|
||||
|
||||
private final StringProperty title = new SimpleStringProperty(this, "title");
|
||||
private final ObjectProperty<EventHandler<ActionEvent>> onSelectButtonClicked = new SimpleObjectProperty<>(this, "onSelectButtonClicked");
|
||||
@@ -47,20 +48,25 @@ public final class ImagePickerItem extends BorderPane {
|
||||
private final ObjectProperty<Image> image = new SimpleObjectProperty<>(this, "image");
|
||||
|
||||
public ImagePickerItem() {
|
||||
imageContainer = new ImageContainer(32);
|
||||
imageContainer.setSmooth(false);
|
||||
imageView = new ImageView();
|
||||
imageView.setSmooth(false);
|
||||
imageView.setPreserveRatio(true);
|
||||
|
||||
JFXButton selectButton = FXUtils.newToggleButton4(SVG.EDIT, 20);
|
||||
JFXButton selectButton = new JFXButton();
|
||||
selectButton.setGraphic(SVG.EDIT.createIcon(20));
|
||||
selectButton.onActionProperty().bind(onSelectButtonClicked);
|
||||
selectButton.getStyleClass().add("toggle-icon4");
|
||||
|
||||
JFXButton deleteButton = FXUtils.newToggleButton4(SVG.RESTORE, 20);
|
||||
JFXButton deleteButton = new JFXButton();
|
||||
deleteButton.setGraphic(SVG.RESTORE.createIcon(20));
|
||||
deleteButton.onActionProperty().bind(onDeleteButtonClicked);
|
||||
deleteButton.getStyleClass().add("toggle-icon4");
|
||||
|
||||
FXUtils.installFastTooltip(selectButton, i18n("button.edit"));
|
||||
FXUtils.installFastTooltip(deleteButton, i18n("button.reset"));
|
||||
|
||||
HBox hBox = new HBox();
|
||||
hBox.getChildren().setAll(imageContainer, selectButton, deleteButton);
|
||||
hBox.getChildren().setAll(imageView, selectButton, deleteButton);
|
||||
hBox.setAlignment(Pos.CENTER_RIGHT);
|
||||
hBox.setSpacing(8);
|
||||
setRight(hBox);
|
||||
@@ -72,7 +78,7 @@ public final class ImagePickerItem extends BorderPane {
|
||||
vBox.setAlignment(Pos.CENTER_LEFT);
|
||||
setLeft(vBox);
|
||||
|
||||
imageContainer.imageProperty().bind(image);
|
||||
imageView.imageProperty().bind(image);
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
@@ -122,4 +128,8 @@ public final class ImagePickerItem extends BorderPane {
|
||||
public void setImage(Image image) {
|
||||
this.image.set(image);
|
||||
}
|
||||
|
||||
public ImageView getImageView() {
|
||||
return imageView;
|
||||
}
|
||||
}
|
||||
@@ -20,18 +20,16 @@ package org.jackhuang.hmcl.ui.construct;
|
||||
import com.jfoenix.controls.JFXPopup;
|
||||
import javafx.beans.InvalidationListener;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.property.ListProperty;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleListProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.beans.property.*;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.css.PseudoClass;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.input.*;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.input.MouseButton;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.input.ScrollEvent;
|
||||
import javafx.scene.layout.*;
|
||||
import org.jackhuang.hmcl.ui.FXUtils;
|
||||
import org.jackhuang.hmcl.ui.SVG;
|
||||
import org.jackhuang.hmcl.util.javafx.MappedObservableList;
|
||||
@@ -83,8 +81,6 @@ public final class LineSelectButton<T> extends LineButton {
|
||||
PopupMenu popupMenu = new PopupMenu();
|
||||
this.popup = new JFXPopup(popupMenu);
|
||||
|
||||
popupMenu.addEventHandler(KeyEvent.KEY_PRESSED, this::handleKeyEvent);
|
||||
|
||||
ripplerContainer.addEventFilter(ScrollEvent.ANY, ignored -> popup.hide());
|
||||
|
||||
Bindings.bindContent(popupMenu.getContent(), MappedObservableList.create(itemsProperty(), item -> {
|
||||
@@ -217,32 +213,4 @@ public final class LineSelectButton<T> extends LineButton {
|
||||
return items.get();
|
||||
}
|
||||
|
||||
private void handleKeyEvent(KeyEvent event) {
|
||||
ObservableList<T> list = getItems();
|
||||
if (list == null || list.isEmpty()) return;
|
||||
int index = list.indexOf(getValue());
|
||||
|
||||
var code = event.getCode();
|
||||
|
||||
if (code == KeyCode.UP) {
|
||||
if (index > 0) {
|
||||
setValue(list.get(index - 1));
|
||||
} else {
|
||||
setValue(list.get(list.size() - 1));
|
||||
}
|
||||
event.consume();
|
||||
} else if (code == KeyCode.DOWN) {
|
||||
if (index < list.size() - 1) {
|
||||
setValue(list.get(index + 1));
|
||||
} else {
|
||||
setValue(list.get(0));
|
||||
}
|
||||
event.consume();
|
||||
} else if (code == KeyCode.ENTER || code == KeyCode.ESCAPE) {
|
||||
if (popup != null && popup.isShowing()) {
|
||||
popup.hide();
|
||||
event.consume();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -189,7 +189,6 @@ public class SpinnerPane extends Control {
|
||||
|
||||
Skin(SpinnerPane control) {
|
||||
super(control);
|
||||
root.setClip(null);
|
||||
|
||||
updateContent();
|
||||
this.getChildren().setAll(root);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.jackhuang.hmcl.ui.construct;
|
||||
|
||||
import com.jfoenix.controls.JFXRippler;
|
||||
import javafx.animation.*;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.binding.Bindings;
|
||||
@@ -25,11 +26,12 @@ import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.css.PseudoClass;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Side;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.transform.Rotate;
|
||||
import javafx.scene.transform.Scale;
|
||||
import javafx.util.Duration;
|
||||
@@ -155,6 +157,8 @@ public class TabHeader extends Control implements TabControl, PageAware {
|
||||
|
||||
private static final PseudoClass SELECTED_PSEUDOCLASS_STATE = PseudoClass.getPseudoClass("selected");
|
||||
|
||||
private final Color ripplerColor = Color.valueOf("#FFFF8D");
|
||||
|
||||
private final HeaderContainer header;
|
||||
private boolean isSelectingTab = false;
|
||||
private Tab<?> selectedTab;
|
||||
@@ -210,6 +214,7 @@ public class TabHeader extends Control implements TabControl, PageAware {
|
||||
selectedTabLine.getStyleClass().addAll("tab-selected-line");
|
||||
selectedTabLine.setPrefHeight(2);
|
||||
selectedTabLine.setPrefWidth(2);
|
||||
selectedTabLine.setBackground(new Background(new BackgroundFill(ripplerColor, CornerRadii.EMPTY, Insets.EMPTY)));
|
||||
getChildren().setAll(headersRegion, selectedTabLine);
|
||||
headersRegion.setPickOnBounds(false);
|
||||
headersRegion.prefHeightProperty().bind(heightProperty());
|
||||
@@ -588,6 +593,7 @@ public class TabHeader extends Control implements TabControl, PageAware {
|
||||
private final Tab<?> tab;
|
||||
private final Label tabText;
|
||||
private final BorderPane inner;
|
||||
private final JFXRippler rippler;
|
||||
|
||||
public TabHeaderContainer(Tab<?> tab) {
|
||||
this.tab = tab;
|
||||
@@ -598,8 +604,9 @@ public class TabHeader extends Control implements TabControl, PageAware {
|
||||
inner = new BorderPane();
|
||||
inner.setCenter(tabText);
|
||||
inner.getStyleClass().add("tab-container");
|
||||
inner.setMouseTransparent(true);
|
||||
RipplerContainer rippler = new RipplerContainer(inner);
|
||||
rippler = new JFXRippler(inner, JFXRippler.RipplerPos.FRONT);
|
||||
rippler.getStyleClass().add("tab-rippler");
|
||||
rippler.setRipplerFill(ripplerColor);
|
||||
getChildren().setAll(rippler);
|
||||
|
||||
FXUtils.onChangeAndOperate(tab.selectedProperty(), selected -> inner.pseudoClassStateChanged(SELECTED_PSEUDOCLASS_STATE, selected));
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.jackhuang.hmcl.util.TaskCancellationAction;
|
||||
import org.jackhuang.hmcl.util.i18n.I18n;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static org.jackhuang.hmcl.ui.FXUtils.onEscPressed;
|
||||
@@ -82,9 +83,8 @@ public class TaskExecutorDialogPane extends BorderPane {
|
||||
setCancel(cancel);
|
||||
|
||||
btnCancel.setOnAction(e -> {
|
||||
Optional.ofNullable(executor).ifPresent(TaskExecutor::cancel);
|
||||
if (onCancel.getCancellationAction() != null) {
|
||||
if (executor != null)
|
||||
executor.cancel();
|
||||
onCancel.getCancellationAction().accept(this);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -106,18 +106,13 @@ public final class TaskListPane extends StackPane {
|
||||
}
|
||||
|
||||
@FXThread
|
||||
private void addStagesHints(@NotNull Collection<Task.StagesHint> hints) {
|
||||
for (Task.StagesHint hint : hints) {
|
||||
StageNode node = stageNodes.get(hint.stage());
|
||||
|
||||
if (node == null) {
|
||||
node = new StageNode(hint.stage());
|
||||
stageNodes.put(hint.stage(), node);
|
||||
private void addStages(@NotNull Collection<String> stages) {
|
||||
for (String stage : stages) {
|
||||
stageNodes.computeIfAbsent(stage, s -> {
|
||||
StageNode node = new StageNode(stage);
|
||||
listView.getItems().add(node);
|
||||
}
|
||||
for (String stage : hint.aliases()) {
|
||||
stageNodes.put(stage, node);
|
||||
}
|
||||
return node;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +129,7 @@ public final class TaskListPane extends StackPane {
|
||||
Platform.runLater(() -> {
|
||||
stageNodes.clear();
|
||||
listView.getItems().clear();
|
||||
addStagesHints(executor.getHints());
|
||||
addStages(executor.getStages());
|
||||
updateProgressNodePadding();
|
||||
});
|
||||
}
|
||||
@@ -143,7 +138,7 @@ public final class TaskListPane extends StackPane {
|
||||
public void onReady(Task<?> task) {
|
||||
if (task instanceof Task.StagesHintTask) {
|
||||
Platform.runLater(() -> {
|
||||
addStagesHints(((Task<?>.StagesHintTask) task).getHints());
|
||||
addStages(((Task<?>.StagesHintTask) task).getStages());
|
||||
updateProgressNodePadding();
|
||||
});
|
||||
}
|
||||
@@ -399,8 +394,6 @@ public final class TaskListPane extends StackPane {
|
||||
}
|
||||
|
||||
private static final class StageNode extends Node {
|
||||
private int runningTasksCount = 0;
|
||||
|
||||
private enum Status {
|
||||
WAITING(SVG.MORE_HORIZ),
|
||||
RUNNING(SVG.ARROW_FORWARD),
|
||||
@@ -461,23 +454,17 @@ public final class TaskListPane extends StackPane {
|
||||
}
|
||||
|
||||
private void begin() {
|
||||
runningTasksCount++;
|
||||
if (status.get() == Status.WAITING || status.get() == Status.SUCCESS) {
|
||||
if (status.get() == Status.WAITING) {
|
||||
status.set(Status.RUNNING);
|
||||
}
|
||||
}
|
||||
|
||||
public void succeed() {
|
||||
runningTasksCount = Math.max(0, runningTasksCount - 1);
|
||||
|
||||
if (runningTasksCount == 0) {
|
||||
status.set(Status.SUCCESS);
|
||||
}
|
||||
public void fail() {
|
||||
status.set(Status.FAILED);
|
||||
}
|
||||
|
||||
public void fail() {
|
||||
runningTasksCount = Math.max(0, runningTasksCount - 1);
|
||||
status.set(Status.FAILED);
|
||||
public void succeed() {
|
||||
status.set(Status.SUCCESS);
|
||||
}
|
||||
|
||||
public void count() {
|
||||
|
||||
@@ -39,7 +39,6 @@ import javafx.scene.paint.Color;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.StageStyle;
|
||||
import javafx.util.Duration;
|
||||
import org.jackhuang.hmcl.Launcher;
|
||||
import org.jackhuang.hmcl.ui.FXUtils;
|
||||
import org.jackhuang.hmcl.ui.animation.AnimationUtils;
|
||||
import org.jackhuang.hmcl.ui.animation.Motion;
|
||||
@@ -47,10 +46,13 @@ import org.jackhuang.hmcl.ui.wizard.Navigation;
|
||||
import org.jackhuang.hmcl.util.platform.OperatingSystem;
|
||||
|
||||
public class Decorator extends Control {
|
||||
private final ListProperty<Node> drawer = new SimpleListProperty<>(FXCollections.observableArrayList());
|
||||
private final ListProperty<Node> content = new SimpleListProperty<>(FXCollections.observableArrayList());
|
||||
private final ListProperty<Node> container = new SimpleListProperty<>(FXCollections.observableArrayList());
|
||||
private final ObjectProperty<Background> contentBackground = new SimpleObjectProperty<>();
|
||||
private final ObjectProperty<DecoratorPage.State> state = new SimpleObjectProperty<>();
|
||||
private final StringProperty drawerTitle = new SimpleStringProperty();
|
||||
private final ObjectProperty<Runnable> onCloseButtonAction = new SimpleObjectProperty<>();
|
||||
private final ObjectProperty<EventHandler<ActionEvent>> onCloseNavButtonAction = new SimpleObjectProperty<>();
|
||||
private final ObjectProperty<EventHandler<ActionEvent>> onBackNavButtonAction = new SimpleObjectProperty<>();
|
||||
private final ObjectProperty<EventHandler<ActionEvent>> onRefreshNavButtonAction = new SimpleObjectProperty<>();
|
||||
@@ -115,6 +117,18 @@ public class Decorator extends Control {
|
||||
this.drawerWrapper = drawerWrapper;
|
||||
}
|
||||
|
||||
public ObservableList<Node> getDrawer() {
|
||||
return drawer.get();
|
||||
}
|
||||
|
||||
public ListProperty<Node> drawerProperty() {
|
||||
return drawer;
|
||||
}
|
||||
|
||||
public void setDrawer(ObservableList<Node> drawer) {
|
||||
this.drawer.set(drawer);
|
||||
}
|
||||
|
||||
public ObservableList<Node> getContent() {
|
||||
return content.get();
|
||||
}
|
||||
@@ -139,6 +153,30 @@ public class Decorator extends Control {
|
||||
this.state.set(state);
|
||||
}
|
||||
|
||||
public String getDrawerTitle() {
|
||||
return drawerTitle.get();
|
||||
}
|
||||
|
||||
public StringProperty drawerTitleProperty() {
|
||||
return drawerTitle;
|
||||
}
|
||||
|
||||
public void setDrawerTitle(String drawerTitle) {
|
||||
this.drawerTitle.set(drawerTitle);
|
||||
}
|
||||
|
||||
public Runnable getOnCloseButtonAction() {
|
||||
return onCloseButtonAction.get();
|
||||
}
|
||||
|
||||
public ObjectProperty<Runnable> onCloseButtonActionProperty() {
|
||||
return onCloseButtonAction;
|
||||
}
|
||||
|
||||
public void setOnCloseButtonAction(Runnable onCloseButtonAction) {
|
||||
this.onCloseButtonAction.set(onCloseButtonAction);
|
||||
}
|
||||
|
||||
public ObservableList<Node> getContainer() {
|
||||
return container.get();
|
||||
}
|
||||
@@ -263,26 +301,7 @@ public class Decorator extends Control {
|
||||
}
|
||||
|
||||
public void close() {
|
||||
if (AnimationUtils.playWindowAnimation()) {
|
||||
Timeline timeline = new Timeline(
|
||||
new KeyFrame(Duration.millis(0),
|
||||
new KeyValue(opacityProperty(), 1, Motion.EASE),
|
||||
new KeyValue(scaleXProperty(), 1, Motion.EASE),
|
||||
new KeyValue(scaleYProperty(), 1, Motion.EASE),
|
||||
new KeyValue(scaleZProperty(), 0.3, Motion.EASE)
|
||||
),
|
||||
new KeyFrame(Duration.millis(200),
|
||||
new KeyValue(opacityProperty(), 0, Motion.EASE),
|
||||
new KeyValue(scaleXProperty(), 0.8, Motion.EASE),
|
||||
new KeyValue(scaleYProperty(), 0.8, Motion.EASE),
|
||||
new KeyValue(scaleZProperty(), 0.8, Motion.EASE)
|
||||
)
|
||||
);
|
||||
timeline.setOnFinished(event -> Launcher.stopApplication());
|
||||
timeline.play();
|
||||
} else {
|
||||
Launcher.stopApplication();
|
||||
}
|
||||
onCloseButtonAction.get().run();
|
||||
}
|
||||
|
||||
public void capableDraggingWindow(Node node) {
|
||||
|
||||
@@ -20,6 +20,9 @@ package org.jackhuang.hmcl.ui.decorator;
|
||||
import com.jfoenix.controls.JFXSnackbar;
|
||||
import com.jfoenix.controls.JFXSnackbarLayout;
|
||||
import javafx.animation.Interpolator;
|
||||
import javafx.animation.KeyFrame;
|
||||
import javafx.animation.KeyValue;
|
||||
import javafx.animation.Timeline;
|
||||
import javafx.beans.InvalidationListener;
|
||||
import javafx.beans.WeakInvalidationListener;
|
||||
import javafx.geometry.Insets;
|
||||
@@ -34,6 +37,7 @@ import javafx.scene.paint.Color;
|
||||
import javafx.scene.paint.Paint;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
import org.jackhuang.hmcl.Launcher;
|
||||
import org.jackhuang.hmcl.Metadata;
|
||||
import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorDnD;
|
||||
import org.jackhuang.hmcl.setting.EnumBackgroundImage;
|
||||
@@ -43,6 +47,7 @@ import org.jackhuang.hmcl.ui.Controllers;
|
||||
import org.jackhuang.hmcl.ui.DialogUtils;
|
||||
import org.jackhuang.hmcl.ui.FXUtils;
|
||||
import org.jackhuang.hmcl.ui.account.AddAuthlibInjectorServerPane;
|
||||
import org.jackhuang.hmcl.ui.animation.AnimationUtils;
|
||||
import org.jackhuang.hmcl.ui.animation.ContainerAnimations;
|
||||
import org.jackhuang.hmcl.ui.animation.Motion;
|
||||
import org.jackhuang.hmcl.ui.animation.TransitionPane.AnimationProducer;
|
||||
@@ -76,6 +81,28 @@ public class DecoratorController {
|
||||
|
||||
public DecoratorController(Stage stage, Node mainPage) {
|
||||
decorator = new Decorator(stage);
|
||||
decorator.setOnCloseButtonAction(() -> {
|
||||
if (AnimationUtils.playWindowAnimation()) {
|
||||
Timeline timeline = new Timeline(
|
||||
new KeyFrame(Duration.millis(0),
|
||||
new KeyValue(decorator.opacityProperty(), 1, Motion.EASE),
|
||||
new KeyValue(decorator.scaleXProperty(), 1, Motion.EASE),
|
||||
new KeyValue(decorator.scaleYProperty(), 1, Motion.EASE),
|
||||
new KeyValue(decorator.scaleZProperty(), 0.3, Motion.EASE)
|
||||
),
|
||||
new KeyFrame(Duration.millis(200),
|
||||
new KeyValue(decorator.opacityProperty(), 0, Motion.EASE),
|
||||
new KeyValue(decorator.scaleXProperty(), 0.8, Motion.EASE),
|
||||
new KeyValue(decorator.scaleYProperty(), 0.8, Motion.EASE),
|
||||
new KeyValue(decorator.scaleZProperty(), 0.8, Motion.EASE)
|
||||
)
|
||||
);
|
||||
timeline.setOnFinished(event -> Launcher.stopApplication());
|
||||
timeline.play();
|
||||
} else {
|
||||
Launcher.stopApplication();
|
||||
}
|
||||
});
|
||||
decorator.titleTransparentProperty().bind(config().titleTransparentProperty());
|
||||
|
||||
navigator = new Navigator();
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.jackhuang.hmcl.ui.construct.RequiredValidator;
|
||||
import org.jackhuang.hmcl.ui.construct.Validator;
|
||||
import org.jackhuang.hmcl.ui.wizard.WizardController;
|
||||
import org.jackhuang.hmcl.util.SettingsMap;
|
||||
import org.jackhuang.hmcl.util.i18n.I18n;
|
||||
|
||||
import static javafx.beans.binding.Bindings.createBooleanBinding;
|
||||
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
||||
@@ -51,11 +50,11 @@ public class InstallersPage extends AbstractInstallersPage {
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return ((RemoteVersion) controller.getSettings().get("game")).getGameVersion();
|
||||
return group.getGame().versionProperty().get().version();
|
||||
}
|
||||
|
||||
private String getVersion(String id) {
|
||||
return I18n.getDisplayVersion((RemoteVersion) controller.getSettings().get(id));
|
||||
return ((RemoteVersion) controller.getSettings().get(id)).getSelfVersion();
|
||||
}
|
||||
|
||||
protected void reload() {
|
||||
@@ -112,7 +111,7 @@ public class InstallersPage extends AbstractInstallersPage {
|
||||
}
|
||||
|
||||
private void setTxtNameWithLoaders() {
|
||||
StringBuilder nameBuilder = new StringBuilder(getTitle());
|
||||
StringBuilder nameBuilder = new StringBuilder(group.getGame().versionProperty().get().version());
|
||||
|
||||
for (InstallerItem library : group.getLibraries()) {
|
||||
String libraryId = library.getLibraryId().replace(LibraryAnalyzer.LibraryType.MINECRAFT.getPatchId(), "");
|
||||
@@ -121,22 +120,23 @@ public class InstallersPage extends AbstractInstallersPage {
|
||||
}
|
||||
|
||||
LibraryAnalyzer.LibraryType libraryType = LibraryAnalyzer.LibraryType.fromPatchId(libraryId);
|
||||
|
||||
if (libraryType != null) {
|
||||
String loaderName = switch (libraryType) {
|
||||
case FORGE -> "Forge";
|
||||
case NEO_FORGE -> "NeoForge";
|
||||
case CLEANROOM -> "Cleanroom";
|
||||
case LEGACY_FABRIC -> "LegacyFabric";
|
||||
case FABRIC -> "Fabric";
|
||||
case LITELOADER -> "LiteLoader";
|
||||
case QUILT -> "Quilt";
|
||||
case OPTIFINE -> "OptiFine";
|
||||
case FORGE -> i18n("install.installer.forge");
|
||||
case NEO_FORGE -> i18n("install.installer.neoforge");
|
||||
case CLEANROOM -> i18n("install.installer.cleanroom");
|
||||
case LEGACY_FABRIC -> i18n("install.installer.legacyfabric").replace(" ", "_");
|
||||
case FABRIC -> i18n("install.installer.fabric");
|
||||
case LITELOADER -> i18n("install.installer.liteloader");
|
||||
case QUILT -> i18n("install.installer.quilt");
|
||||
case OPTIFINE -> i18n("install.installer.optifine");
|
||||
default -> null;
|
||||
};
|
||||
|
||||
if (loaderName != null)
|
||||
nameBuilder.append('-').append(loaderName);
|
||||
if (loaderName == null)
|
||||
continue;
|
||||
|
||||
nameBuilder.append("-").append(loaderName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-24
@@ -47,7 +47,6 @@ public final class ModpackInstallWizardProvider implements WizardProvider {
|
||||
private final Path file;
|
||||
private final String updateVersion;
|
||||
private String iconUrl;
|
||||
private boolean hasSource;
|
||||
|
||||
public ModpackInstallWizardProvider(Profile profile) {
|
||||
this(profile, null, null);
|
||||
@@ -80,7 +79,6 @@ public final class ModpackInstallWizardProvider implements WizardProvider {
|
||||
if (StringUtils.isNotBlank(iconUrl))
|
||||
settings.put(LocalModpackPage.MODPACK_ICON_URL, iconUrl);
|
||||
settings.put(ModpackPage.PROFILE, profile);
|
||||
hasSource = settings.containsKey(LocalModpackPage.MODPACK_FILE) || settings.containsKey(RemoteModpackPage.MODPACK_SERVER_MANIFEST);
|
||||
}
|
||||
|
||||
private Task<?> finishModpackInstallingAsync(SettingsMap settings) {
|
||||
@@ -147,30 +145,20 @@ public final class ModpackInstallWizardProvider implements WizardProvider {
|
||||
return finishModpackInstallingAsync(settings);
|
||||
}
|
||||
|
||||
private static Node createModpackInstallPage(WizardController controller) {
|
||||
if (controller.getSettings().containsKey(LocalModpackPage.MODPACK_FILE))
|
||||
return new LocalModpackPage(controller);
|
||||
else if (controller.getSettings().containsKey(RemoteModpackPage.MODPACK_SERVER_MANIFEST))
|
||||
return new RemoteModpackPage(controller);
|
||||
else
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node createPage(WizardController controller, int step, SettingsMap settings) {
|
||||
if (hasSource) {
|
||||
return switch (step) {
|
||||
case 0 -> createModpackInstallPage(controller);
|
||||
default -> throw new IllegalStateException(
|
||||
"error step " + step + ", settings: " + settings + ", pages: " + controller.getPages());
|
||||
};
|
||||
} else {
|
||||
return switch (step) {
|
||||
case 0 -> new ModpackSelectionPage(controller);
|
||||
case 1 -> createModpackInstallPage(controller);
|
||||
default -> throw new IllegalStateException(
|
||||
"error step " + step + ", settings: " + settings + ", pages: " + controller.getPages());
|
||||
};
|
||||
switch (step) {
|
||||
case 0:
|
||||
return new ModpackSelectionPage(controller);
|
||||
case 1:
|
||||
if (controller.getSettings().containsKey(LocalModpackPage.MODPACK_FILE))
|
||||
return new LocalModpackPage(controller);
|
||||
else if (controller.getSettings().containsKey(RemoteModpackPage.MODPACK_SERVER_MANIFEST))
|
||||
return new RemoteModpackPage(controller);
|
||||
else
|
||||
throw new IllegalArgumentException();
|
||||
default:
|
||||
throw new IllegalStateException("error step " + step + ", settings: " + settings + ", pages: " + controller.getPages());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,11 +42,11 @@ public abstract class ModpackPage extends SpinnerPane implements WizardPage {
|
||||
{
|
||||
var archiveNamePane = new LinePane();
|
||||
{
|
||||
archiveNamePane.setTitle(i18n("version.name"));
|
||||
archiveNamePane.setTitle(i18n("archive.file.name"));
|
||||
|
||||
txtModpackName = new JFXTextField();
|
||||
txtModpackName.setPrefWidth(300);
|
||||
FXUtils.setLimitHeight(archiveNamePane, 75);
|
||||
// FIXME: Validator are not shown properly
|
||||
// BorderPane.setMargin(txtModpackName, new Insets(0, 0, 8, 32));
|
||||
BorderPane.setAlignment(txtModpackName, Pos.CENTER_RIGHT);
|
||||
archiveNamePane.setRight(txtModpackName);
|
||||
|
||||
+6
-5
@@ -40,6 +40,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.zip.ZipException;
|
||||
|
||||
@@ -77,21 +78,21 @@ public final class UpdateInstallerWizardProvider implements WizardProvider {
|
||||
// We remove library but not save it,
|
||||
// so if installation failed will not break down current version.
|
||||
Task<Version> ret = Task.supplyAsync(() -> version);
|
||||
var hints = new ArrayList<Task.StagesHint>();
|
||||
List<String> stages = new ArrayList<>();
|
||||
for (Object value : settings.asStringMap().values()) {
|
||||
if (value instanceof RemoteVersion remoteVersion) {
|
||||
ret = ret.thenComposeAsync(version -> dependencyManager.installLibraryAsync(version, remoteVersion));
|
||||
hints.add(new Task.StagesHint(String.format("hmcl.install.%s:%s", remoteVersion.getLibraryId(), remoteVersion.getSelfVersion())));
|
||||
stages.add(String.format("hmcl.install.%s:%s", remoteVersion.getLibraryId(), remoteVersion.getSelfVersion()));
|
||||
if ("game".equals(remoteVersion.getLibraryId())) {
|
||||
hints.add(new Task.StagesHint("hmcl.install.libraries"));
|
||||
hints.add(new Task.StagesHint("hmcl.install.assets"));
|
||||
stages.add("hmcl.install.libraries");
|
||||
stages.add("hmcl.install.assets");
|
||||
}
|
||||
} else if (value instanceof RemoveVersionAction removeVersionAction) {
|
||||
ret = ret.thenComposeAsync(version -> dependencyManager.removeLibraryAsync(version, removeVersionAction.libraryId));
|
||||
}
|
||||
}
|
||||
|
||||
return ret.thenComposeAsync(profile.getRepository()::saveAsync).thenComposeAsync(profile.getRepository().refreshVersionsAsync()).withStagesHints(hints);
|
||||
return ret.thenComposeAsync(profile.getRepository()::saveAsync).thenComposeAsync(profile.getRepository().refreshVersionsAsync()).withStagesHint(stages);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -278,12 +278,10 @@ public final class VersionsPage extends Control implements WizardPage, Refreshab
|
||||
iconType = VersionIconType.COMMAND;
|
||||
|
||||
imageView.setImage(iconType.getIcon());
|
||||
String displayGameVersion = I18n.getDisplayVersion(GameVersionNumber.asGameVersion(remoteVersion.getGameVersion()));
|
||||
|
||||
if (twoLineListItem.getSubtitle() == null)
|
||||
twoLineListItem.setSubtitle(displayGameVersion);
|
||||
twoLineListItem.setSubtitle(remoteVersion.getGameVersion());
|
||||
else
|
||||
twoLineListItem.addTag(displayGameVersion);
|
||||
twoLineListItem.addTag(remoteVersion.getGameVersion());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,15 +221,10 @@ public final class ModpackInfoPage extends Control implements WizardPage {
|
||||
|
||||
list.getContent().addAll(
|
||||
createTextFieldLinePane(i18n("modpack.name"), skinnable.name, new RequiredValidator()),
|
||||
createTextFieldLinePane(i18n("archive.author"), skinnable.author, new RequiredValidator()),
|
||||
createTextFieldLinePane(i18n("archive.version"), skinnable.version, new RequiredValidator())
|
||||
);
|
||||
|
||||
if (skinnable.options.isRequireAuthor()) {
|
||||
list.getContent().add(
|
||||
createTextFieldLinePane(i18n("archive.author"), skinnable.author, new RequiredValidator())
|
||||
);
|
||||
}
|
||||
|
||||
if (skinnable.options.isRequireFileApi()) {
|
||||
list.getContent().add(createTextFieldLinePane(
|
||||
i18n("modpack.file_api"), skinnable.fileApi,
|
||||
|
||||
@@ -241,7 +241,9 @@ public final class JavaManagementPage extends ListPageBase<JavaRuntime> {
|
||||
HBox right = new HBox();
|
||||
right.setAlignment(Pos.CENTER_RIGHT);
|
||||
{
|
||||
JFXButton revealButton = FXUtils.newToggleButton4(SVG.FOLDER_OPEN);
|
||||
JFXButton revealButton = new JFXButton();
|
||||
revealButton.setGraphic(SVG.FOLDER_OPEN.createIcon());
|
||||
revealButton.getStyleClass().add("toggle-icon4");
|
||||
revealButton.setOnAction(e -> {
|
||||
JavaRuntime java = getItem();
|
||||
if (java != null)
|
||||
|
||||
@@ -157,20 +157,26 @@ public final class JavaRestorePage extends ListPageBase<JavaRestorePage.Disabled
|
||||
HBox right = new HBox();
|
||||
right.setAlignment(Pos.CENTER_RIGHT);
|
||||
{
|
||||
JFXButton revealButton = FXUtils.newToggleButton4(SVG.FOLDER_OPEN);
|
||||
JFXButton revealButton = new JFXButton();
|
||||
revealButton.getStyleClass().add("toggle-icon4");
|
||||
revealButton.setGraphic(SVG.FOLDER_OPEN.createIcon());
|
||||
revealButton.setOnAction(e -> skinnable.onReveal());
|
||||
FXUtils.installFastTooltip(revealButton, i18n("reveal.in_file_manager"));
|
||||
|
||||
if (skinnable.realPath == null) {
|
||||
revealButton.setDisable(true);
|
||||
|
||||
JFXButton removeButton = FXUtils.newToggleButton4(SVG.DELETE);
|
||||
JFXButton removeButton = new JFXButton();
|
||||
removeButton.getStyleClass().add("toggle-icon4");
|
||||
removeButton.setGraphic(SVG.DELETE.createIcon());
|
||||
removeButton.setOnAction(e -> skinnable.onRemove());
|
||||
FXUtils.installFastTooltip(removeButton, i18n("java.disabled.management.remove"));
|
||||
|
||||
right.getChildren().setAll(revealButton, removeButton);
|
||||
} else {
|
||||
JFXButton restoreButton = FXUtils.newToggleButton4(SVG.RESTORE);
|
||||
JFXButton restoreButton = new JFXButton();
|
||||
restoreButton.getStyleClass().add("toggle-icon4");
|
||||
restoreButton.setGraphic(SVG.RESTORE.createIcon());
|
||||
restoreButton.setOnAction(e -> skinnable.onRestore());
|
||||
FXUtils.installFastTooltip(restoreButton, i18n("java.disabled.management.restore"));
|
||||
|
||||
|
||||
@@ -227,7 +227,7 @@ public final class MainPage extends StackPane implements DecoratorPage {
|
||||
launchLabel.setText(i18n("version.launch.empty"));
|
||||
currentLabel.setText(null);
|
||||
graphic.getChildren().setAll(launchLabel);
|
||||
FXUtils.setOnActionWithCooldown(launchButton, MainPage.this::launchNoGame);
|
||||
launchButton.setOnAction(e -> MainPage.this.launchNoGame());
|
||||
if (tooltip == null)
|
||||
tooltip = new Tooltip(i18n("version.launch.empty.tooltip"));
|
||||
FXUtils.installFastTooltip(launchButton, tooltip);
|
||||
@@ -235,7 +235,7 @@ public final class MainPage extends StackPane implements DecoratorPage {
|
||||
launchLabel.setText(i18n("version.launch"));
|
||||
currentLabel.setText(currentGame);
|
||||
graphic.getChildren().setAll(launchLabel, currentLabel);
|
||||
FXUtils.setOnActionWithCooldown(launchButton, MainPage.this::launch);
|
||||
launchButton.setOnAction(e -> MainPage.this.launch());
|
||||
if (tooltip != null)
|
||||
Tooltip.uninstall(launchButton, tooltip);
|
||||
}
|
||||
|
||||
@@ -226,7 +226,9 @@ public class PersonalizationPage extends StackPane {
|
||||
.fallbackTo(12.0)
|
||||
.asPredicate(Validator.addTo(txtLogFontSize)));
|
||||
|
||||
JFXButton clearButton = FXUtils.newToggleButton4(SVG.RESTORE);
|
||||
JFXButton clearButton = new JFXButton();
|
||||
clearButton.getStyleClass().add("toggle-icon4");
|
||||
clearButton.setGraphic(SVG.RESTORE.createIcon());
|
||||
clearButton.setOnAction(e -> cboLogFont.setValue(null));
|
||||
|
||||
FXUtils.installFastTooltip(clearButton, i18n("button.reset"));
|
||||
@@ -274,7 +276,9 @@ public class PersonalizationPage extends StackPane {
|
||||
cboFont.setValue(config().getLauncherFontFamily());
|
||||
FXUtils.onChange(cboFont.valueProperty(), FontManager::setFontFamily);
|
||||
|
||||
JFXButton clearButton = FXUtils.newToggleButton4(SVG.RESTORE);
|
||||
JFXButton clearButton = new JFXButton();
|
||||
clearButton.getStyleClass().add("toggle-icon4");
|
||||
clearButton.setGraphic(SVG.RESTORE.createIcon());
|
||||
clearButton.setOnAction(e -> cboFont.setValue(null));
|
||||
|
||||
FXUtils.installFastTooltip(clearButton, i18n("button.reset"));
|
||||
|
||||
@@ -140,8 +140,10 @@ public final class SettingsPage extends ScrollPane {
|
||||
}
|
||||
|
||||
{
|
||||
JFXButton btnUpdate = FXUtils.newToggleButton4(SVG.UPDATE, 20);
|
||||
JFXButton btnUpdate = new JFXButton();
|
||||
btnUpdate.setOnAction(e -> onUpdate());
|
||||
btnUpdate.getStyleClass().add("toggle-icon4");
|
||||
btnUpdate.setGraphic(SVG.UPDATE.createIcon(20));
|
||||
FXUtils.installFastTooltip(btnUpdate, i18n("update.tooltip"));
|
||||
|
||||
updateListener = any -> {
|
||||
|
||||
@@ -60,9 +60,11 @@ public class ProfileListItemSkin extends SkinBase<ProfileListItem> {
|
||||
HBox right = new HBox();
|
||||
right.setAlignment(Pos.CENTER_RIGHT);
|
||||
|
||||
JFXButton btnRemove = FXUtils.newToggleButton4(SVG.CLOSE, 14);
|
||||
JFXButton btnRemove = new JFXButton();
|
||||
btnRemove.setOnAction(e -> skinnable.remove());
|
||||
btnRemove.getStyleClass().add("toggle-icon4");
|
||||
BorderPane.setAlignment(btnRemove, Pos.CENTER);
|
||||
btnRemove.setGraphic(SVG.CLOSE.createIcon(14));
|
||||
right.getChildren().add(btnRemove);
|
||||
root.setRight(right);
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ import org.jackhuang.hmcl.setting.VersionSetting;
|
||||
import org.jackhuang.hmcl.ui.FXUtils;
|
||||
import org.jackhuang.hmcl.ui.construct.*;
|
||||
import org.jackhuang.hmcl.ui.decorator.DecoratorPage;
|
||||
import org.jackhuang.hmcl.util.i18n.I18n;
|
||||
import org.jackhuang.hmcl.util.io.FileUtils;
|
||||
import org.jackhuang.hmcl.util.platform.OperatingSystem;
|
||||
import org.jackhuang.hmcl.util.platform.Platform;
|
||||
@@ -171,10 +170,6 @@ public final class AdvancedVersionSettingPage extends StackPane implements Decor
|
||||
rendererPane = new LineSelectButton<>();
|
||||
rendererPane.setTitle(i18n("settings.advanced.renderer"));
|
||||
rendererPane.setConverter(e -> i18n("settings.advanced.renderer." + e.name().toLowerCase(Locale.ROOT)));
|
||||
rendererPane.setDescriptionConverter(e -> {
|
||||
String bundleKey = "settings.advanced.renderer." + e.name().toLowerCase(Locale.ROOT) + ".desc";
|
||||
return I18n.hasKey(bundleKey) ? i18n(bundleKey) : null;
|
||||
});
|
||||
rendererPane.setItems(Renderer.values());
|
||||
|
||||
noJVMArgsPane = new LineToggleButton();
|
||||
|
||||
@@ -21,7 +21,6 @@ import javafx.beans.property.BooleanProperty;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.scene.control.Skin;
|
||||
import javafx.stage.FileChooser;
|
||||
import org.jackhuang.hmcl.game.World;
|
||||
import org.jackhuang.hmcl.mod.Datapack;
|
||||
import org.jackhuang.hmcl.task.Schedulers;
|
||||
import org.jackhuang.hmcl.task.Task;
|
||||
@@ -45,13 +44,13 @@ import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
||||
import static org.jackhuang.hmcl.util.logging.Logger.LOG;
|
||||
|
||||
public final class DatapackListPage extends ListPageBase<DatapackListPageSkin.DatapackInfoObject> implements WorldManagePage.WorldRefreshable {
|
||||
private final World world;
|
||||
private final Path worldDir;
|
||||
private final Datapack datapack;
|
||||
final BooleanProperty readOnly;
|
||||
|
||||
public DatapackListPage(WorldManagePage worldManagePage) {
|
||||
world = worldManagePage.getWorld();
|
||||
datapack = new Datapack(world.getFile().resolve("datapacks"));
|
||||
this.worldDir = worldManagePage.getWorld().getFile();
|
||||
datapack = new Datapack(worldDir.resolve("datapacks"));
|
||||
setItems(MappedObservableList.create(datapack.getPacks(), DatapackListPageSkin.DatapackInfoObject::new));
|
||||
readOnly = worldManagePage.readOnlyProperty();
|
||||
FXUtils.applyDragListener(this, it -> Objects.equals("zip", FileUtils.getExtension(it)),
|
||||
@@ -69,7 +68,7 @@ public final class DatapackListPage extends ListPageBase<DatapackListPageSkin.Da
|
||||
|
||||
private void installSingleDatapack(Path datapack) {
|
||||
try {
|
||||
this.datapack.installPack(datapack, world.getGameVersion());
|
||||
this.datapack.installPack(datapack);
|
||||
} catch (IOException | IllegalArgumentException e) {
|
||||
LOG.warning("Unable to parse datapack file " + datapack, e);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import javafx.scene.Node;
|
||||
import javafx.scene.control.SelectionMode;
|
||||
import javafx.scene.control.SkinBase;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
@@ -49,7 +50,10 @@ 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.ui.construct.ComponentList;
|
||||
import org.jackhuang.hmcl.ui.construct.MDListCell;
|
||||
import org.jackhuang.hmcl.ui.construct.SpinnerPane;
|
||||
import org.jackhuang.hmcl.ui.construct.TwoLineListItem;
|
||||
import org.jackhuang.hmcl.util.io.CompressingUtils;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -270,20 +274,20 @@ final class DatapackListPageSkin extends SkinBase<DatapackListPage> {
|
||||
}
|
||||
}
|
||||
|
||||
public void loadIcon(ImageContainer imageContainer, @Nullable WeakReference<ObjectProperty<DatapackInfoObject>> current) {
|
||||
public void loadIcon(ImageView imageView, @Nullable WeakReference<ObjectProperty<DatapackInfoObject>> current) {
|
||||
SoftReference<CompletableFuture<Image>> iconCache = this.iconCache;
|
||||
CompletableFuture<Image> imageFuture;
|
||||
if (iconCache != null && (imageFuture = iconCache.get()) != null) {
|
||||
Image image = imageFuture.getNow(null);
|
||||
if (image != null) {
|
||||
imageContainer.setImage(image);
|
||||
imageView.setImage(image);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
imageFuture = CompletableFuture.supplyAsync(this::loadIcon, Schedulers.io());
|
||||
this.iconCache = new SoftReference<>(imageFuture);
|
||||
}
|
||||
imageContainer.setImage(FXUtils.newBuiltinImage("/assets/img/unknown_pack.png"));
|
||||
imageView.setImage(FXUtils.newBuiltinImage("/assets/img/unknown_pack.png"));
|
||||
imageFuture.thenAcceptAsync(image -> {
|
||||
if (current != null) {
|
||||
ObjectProperty<DatapackInfoObject> infoObjectProperty = current.get();
|
||||
@@ -292,7 +296,7 @@ final class DatapackListPageSkin extends SkinBase<DatapackListPage> {
|
||||
return;
|
||||
}
|
||||
}
|
||||
imageContainer.setImage(image);
|
||||
imageView.setImage(image);
|
||||
}, Schedulers.javafx());
|
||||
|
||||
}
|
||||
@@ -300,7 +304,7 @@ final class DatapackListPageSkin extends SkinBase<DatapackListPage> {
|
||||
|
||||
private final class DatapackInfoListCell extends MDListCell<DatapackInfoObject> {
|
||||
final JFXCheckBox checkBox = new JFXCheckBox();
|
||||
ImageContainer imageContainer = new ImageContainer(32);
|
||||
ImageView imageView = new ImageView();
|
||||
final TwoLineListItem content = new TwoLineListItem();
|
||||
BooleanProperty booleanProperty;
|
||||
|
||||
@@ -316,10 +320,13 @@ final class DatapackListPageSkin extends SkinBase<DatapackListPage> {
|
||||
|
||||
checkBox.disableProperty().bind(isReadOnlyProperty);
|
||||
|
||||
imageContainer.setImage(FXUtils.newBuiltinImage("/assets/img/unknown_pack.png"));
|
||||
imageView.setFitWidth(32);
|
||||
imageView.setFitHeight(32);
|
||||
imageView.setPreserveRatio(true);
|
||||
imageView.setImage(FXUtils.newBuiltinImage("/assets/img/unknown_pack.png"));
|
||||
|
||||
StackPane.setMargin(container, new Insets(8));
|
||||
container.getChildren().setAll(checkBox, imageContainer, content);
|
||||
container.getChildren().setAll(checkBox, imageView, content);
|
||||
getContainer().getChildren().setAll(container);
|
||||
|
||||
getContainer().getParent().addEventHandler(MouseEvent.MOUSE_PRESSED, mouseEvent -> handleSelect(this, mouseEvent));
|
||||
@@ -334,7 +341,7 @@ final class DatapackListPageSkin extends SkinBase<DatapackListPage> {
|
||||
checkBox.selectedProperty().unbindBidirectional(booleanProperty);
|
||||
}
|
||||
checkBox.selectedProperty().bindBidirectional(booleanProperty = dataItem.activeProperty);
|
||||
dataItem.loadIcon(imageContainer, new WeakReference<>(this.itemProperty()));
|
||||
dataItem.loadIcon(imageView, new WeakReference<>(this.itemProperty()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,10 +17,8 @@
|
||||
*/
|
||||
package org.jackhuang.hmcl.ui.versions;
|
||||
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import com.jfoenix.controls.JFXComboBox;
|
||||
import com.jfoenix.controls.JFXListView;
|
||||
import com.jfoenix.controls.JFXTextField;
|
||||
import com.jfoenix.controls.*;
|
||||
import com.jfoenix.effects.JFXDepthManager;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.binding.ObjectBinding;
|
||||
import javafx.beans.property.*;
|
||||
@@ -34,6 +32,7 @@ import javafx.scene.Cursor;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.layout.*;
|
||||
@@ -49,7 +48,10 @@ import org.jackhuang.hmcl.task.Task;
|
||||
import org.jackhuang.hmcl.ui.Controllers;
|
||||
import org.jackhuang.hmcl.ui.FXUtils;
|
||||
import org.jackhuang.hmcl.ui.WeakListenerHolder;
|
||||
import org.jackhuang.hmcl.ui.construct.*;
|
||||
import org.jackhuang.hmcl.ui.construct.NoneMultipleSelectionModel;
|
||||
import org.jackhuang.hmcl.ui.construct.RipplerContainer;
|
||||
import org.jackhuang.hmcl.ui.construct.SpinnerPane;
|
||||
import org.jackhuang.hmcl.ui.construct.TwoLineListItem;
|
||||
import org.jackhuang.hmcl.ui.decorator.DecoratorPage;
|
||||
import org.jackhuang.hmcl.util.*;
|
||||
import org.jackhuang.hmcl.util.i18n.I18n;
|
||||
@@ -530,29 +532,28 @@ public class DownloadListPage extends Control implements DecoratorPage, VersionP
|
||||
private static final Insets PADDING = new Insets(9, 9, 0, 9);
|
||||
|
||||
private final RipplerContainer graphic;
|
||||
private final StackPane wrapper = new StackPane();
|
||||
|
||||
private final TwoLineListItem content = new TwoLineListItem();
|
||||
private final ImageContainer imageContainer = new ImageContainer(40);
|
||||
private final ImageView imageView = new ImageView();
|
||||
|
||||
{
|
||||
setPadding(PADDING);
|
||||
|
||||
HBox container = new HBox(8);
|
||||
container.setPadding(new Insets(8));
|
||||
container.getStyleClass().add("card");
|
||||
container.setCursor(Cursor.HAND);
|
||||
container.setAlignment(Pos.CENTER_LEFT);
|
||||
JFXDepthManager.setDepth(container, 1);
|
||||
|
||||
imageContainer.setMouseTransparent(true);
|
||||
imageView.setFitWidth(40);
|
||||
imageView.setFitHeight(40);
|
||||
|
||||
container.getChildren().setAll(imageContainer, content);
|
||||
container.getChildren().setAll(FXUtils.limitingSize(imageView, 40, 40), content);
|
||||
HBox.setHgrow(content, Priority.ALWAYS);
|
||||
|
||||
this.graphic = new RipplerContainer(container);
|
||||
wrapper.getChildren().setAll(this.graphic);
|
||||
wrapper.getStyleClass().add("card-no-padding");
|
||||
|
||||
FXUtils.onClicked(wrapper, () -> {
|
||||
graphic.setPosition(JFXRippler.RipplerPos.FRONT);
|
||||
FXUtils.onClicked(graphic, () -> {
|
||||
RemoteMod item = getItem();
|
||||
if (item != null)
|
||||
Controllers.navigate(new DownloadPage(getSkinnable(), item, getSkinnable().getProfileVersion(), getSkinnable().callback));
|
||||
@@ -578,8 +579,8 @@ public class DownloadListPage extends Control implements DecoratorPage, VersionP
|
||||
if (getSkinnable().shouldDisplayCategory(category))
|
||||
content.addTag(getSkinnable().getLocalizedCategory(category));
|
||||
}
|
||||
iconLoader.load(imageContainer.imageProperty(), item.getIconUrl());
|
||||
setGraphic(wrapper);
|
||||
iconLoader.load(imageView.imageProperty(), item.getIconUrl());
|
||||
setGraphic(graphic);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -32,6 +32,8 @@ import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.control.Skin;
|
||||
import javafx.scene.control.SkinBase;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.Priority;
|
||||
import javafx.scene.layout.Region;
|
||||
@@ -223,18 +225,25 @@ public class DownloadPage extends Control implements DecoratorPage {
|
||||
VBox pane = new VBox(8);
|
||||
pane.getStyleClass().add("gray-background");
|
||||
pane.setPadding(new Insets(10));
|
||||
ScrollPane scrollPane = new ScrollPane(pane);
|
||||
FXUtils.smoothScrolling(scrollPane);
|
||||
scrollPane.setFitToWidth(true);
|
||||
scrollPane.setFitToHeight(true);
|
||||
|
||||
HBox descriptionPane = new HBox(8);
|
||||
descriptionPane.setMinHeight(Region.USE_PREF_SIZE);
|
||||
descriptionPane.setAlignment(Pos.CENTER);
|
||||
pane.getChildren().add(descriptionPane);
|
||||
descriptionPane.getStyleClass().add("card-non-transparent");
|
||||
BorderPane.setMargin(descriptionPane, new Insets(11, 11, 0, 11));
|
||||
{
|
||||
var imageContainer = new ImageContainer(40);
|
||||
ImageView imageView = new ImageView();
|
||||
imageView.setFitWidth(40);
|
||||
imageView.setFitHeight(40);
|
||||
if (StringUtils.isNotBlank(getSkinnable().addon.getIconUrl())) {
|
||||
imageContainer.imageProperty().bind(FXUtils.newRemoteImage(getSkinnable().addon.getIconUrl(), 80, 80, true, true));
|
||||
imageView.imageProperty().bind(FXUtils.newRemoteImage(getSkinnable().addon.getIconUrl(), 80, 80, true, true));
|
||||
}
|
||||
descriptionPane.getChildren().add(imageContainer);
|
||||
descriptionPane.getChildren().add(FXUtils.limitingSize(imageView, 40, 40));
|
||||
|
||||
TwoLineListItem content = new TwoLineListItem();
|
||||
HBox.setHgrow(content, Priority.ALWAYS);
|
||||
@@ -252,12 +261,14 @@ public class DownloadPage extends Control implements DecoratorPage {
|
||||
openMcmodButton.setExternalLink(getSkinnable().translations.getMcmodUrl(getSkinnable().mod));
|
||||
descriptionPane.getChildren().add(openMcmodButton);
|
||||
openMcmodButton.setMinWidth(Region.USE_PREF_SIZE);
|
||||
FXUtils.installFastTooltip(openMcmodButton, i18n("mods.mcmod"));
|
||||
}
|
||||
|
||||
JFXHyperlink openUrlButton = new JFXHyperlink(control.page.getLocalizedOfficialPage());
|
||||
openUrlButton.setExternalLink(getSkinnable().addon.getPageUrl());
|
||||
descriptionPane.getChildren().add(openUrlButton);
|
||||
openUrlButton.setMinWidth(Region.USE_PREF_SIZE);
|
||||
FXUtils.installFastTooltip(openUrlButton, control.page.getLocalizedOfficialPage());
|
||||
}
|
||||
|
||||
SpinnerPane spinnerPane = new SpinnerPane();
|
||||
@@ -275,13 +286,8 @@ public class DownloadPage extends Control implements DecoratorPage {
|
||||
spinnerPane.setOnFailedAction(e -> getSkinnable().loadModVersions());
|
||||
|
||||
ComponentList list = new ComponentList();
|
||||
ScrollPane scrollPane = new ScrollPane(list);
|
||||
FXUtils.smoothScrolling(scrollPane);
|
||||
scrollPane.setFitToWidth(true);
|
||||
scrollPane.setFitToHeight(true);
|
||||
FXUtils.setOverflowHidden(scrollPane, 8);
|
||||
StackPane.setAlignment(scrollPane, Pos.TOP_CENTER);
|
||||
spinnerPane.setContent(scrollPane);
|
||||
StackPane.setAlignment(list, Pos.TOP_CENTER);
|
||||
spinnerPane.setContent(list);
|
||||
|
||||
FXUtils.onChangeAndOperate(control.loaded, loaded -> {
|
||||
if (control.versions == null) return;
|
||||
@@ -335,7 +341,7 @@ public class DownloadPage extends Control implements DecoratorPage {
|
||||
});
|
||||
}
|
||||
|
||||
getChildren().setAll(pane);
|
||||
getChildren().setAll(scrollPane);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,8 +362,10 @@ public class DownloadPage extends Control implements DecoratorPage {
|
||||
pane.setAlignment(Pos.CENTER_LEFT);
|
||||
TwoLineListItem content = new TwoLineListItem();
|
||||
HBox.setHgrow(content, Priority.ALWAYS);
|
||||
var imageView = new ImageContainer(40);
|
||||
pane.getChildren().setAll(imageView, content);
|
||||
ImageView imageView = new ImageView();
|
||||
imageView.setFitWidth(40);
|
||||
imageView.setFitHeight(40);
|
||||
pane.getChildren().setAll(FXUtils.limitingSize(imageView, 40, 40), content);
|
||||
|
||||
RipplerContainer container = new RipplerContainer(pane);
|
||||
FXUtils.onClicked(container, () -> {
|
||||
@@ -485,7 +493,6 @@ public class DownloadPage extends Control implements DecoratorPage {
|
||||
scrollPane.setFitToWidth(true);
|
||||
scrollPane.setFitToHeight(true);
|
||||
FXUtils.smoothScrolling(scrollPane);
|
||||
FXUtils.setOverflowHidden(scrollPane, 8);
|
||||
spinnerPane.setContent(scrollPane);
|
||||
box.getChildren().add(spinnerPane);
|
||||
VBox.setVgrow(spinnerPane, Priority.SOMETIMES);
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
package org.jackhuang.hmcl.ui.versions;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.image.ImageView;
|
||||
import org.jackhuang.hmcl.event.Event;
|
||||
import org.jackhuang.hmcl.setting.Profile;
|
||||
import org.jackhuang.hmcl.setting.Profiles;
|
||||
@@ -25,26 +27,32 @@ import org.jackhuang.hmcl.setting.VersionIconType;
|
||||
import org.jackhuang.hmcl.ui.FXUtils;
|
||||
import org.jackhuang.hmcl.ui.WeakListenerHolder;
|
||||
import org.jackhuang.hmcl.ui.construct.AdvancedListItem;
|
||||
import org.jackhuang.hmcl.ui.construct.ImageContainer;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
||||
|
||||
public class GameAdvancedListItem extends AdvancedListItem {
|
||||
private final ImageContainer imageContainer;
|
||||
private final ImageView imageView;
|
||||
private final WeakListenerHolder holder = new WeakListenerHolder();
|
||||
private Profile profile;
|
||||
@SuppressWarnings("unused")
|
||||
private Consumer<Event> onVersionIconChangedListener;
|
||||
|
||||
@SuppressWarnings("SuspiciousNameCombination")
|
||||
public GameAdvancedListItem() {
|
||||
this.imageContainer = new ImageContainer(LEFT_GRAPHIC_SIZE);
|
||||
imageContainer.setMouseTransparent(true);
|
||||
AdvancedListItem.setAlignment(imageContainer, Pos.CENTER);
|
||||
setLeftGraphic(imageContainer);
|
||||
this.imageView = new ImageView();
|
||||
FXUtils.limitSize(imageView, LEFT_GRAPHIC_SIZE, LEFT_GRAPHIC_SIZE);
|
||||
imageView.setPreserveRatio(true);
|
||||
imageView.setImage(null);
|
||||
|
||||
Node imageViewWrapper = FXUtils.limitingSize(imageView, LEFT_GRAPHIC_SIZE, LEFT_GRAPHIC_SIZE);
|
||||
imageView.setMouseTransparent(true);
|
||||
AdvancedListItem.setAlignment(imageViewWrapper, Pos.CENTER);
|
||||
setLeftGraphic(imageViewWrapper);
|
||||
|
||||
holder.add(FXUtils.onWeakChangeAndOperate(Profiles.selectedVersionProperty(), this::loadVersion));
|
||||
|
||||
}
|
||||
|
||||
private void loadVersion(String version) {
|
||||
@@ -60,11 +68,11 @@ public class GameAdvancedListItem extends AdvancedListItem {
|
||||
Profiles.getSelectedProfile().getRepository().hasVersion(version)) {
|
||||
setTitle(i18n("version.manage.manage"));
|
||||
setSubtitle(version);
|
||||
imageContainer.setImage(Profiles.getSelectedProfile().getRepository().getVersionIconImage(version));
|
||||
imageView.setImage(Profiles.getSelectedProfile().getRepository().getVersionIconImage(version));
|
||||
} else {
|
||||
setTitle(i18n("version.empty"));
|
||||
setSubtitle(i18n("version.empty.add"));
|
||||
imageContainer.setImage(VersionIconType.DEFAULT.getIcon());
|
||||
imageView.setImage(VersionIconType.DEFAULT.getIcon());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Cursor;
|
||||
import javafx.scene.control.ListCell;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.input.MouseButton;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
@@ -41,7 +42,7 @@ public final class GameListCell extends ListCell<GameListItem> {
|
||||
|
||||
private final Region graphic;
|
||||
|
||||
private final ImageContainer imageView;
|
||||
private final ImageView imageView;
|
||||
private final TwoLineListItem content;
|
||||
|
||||
private final JFXRadioButton chkSelected;
|
||||
@@ -86,7 +87,8 @@ public final class GameListCell extends ListCell<GameListItem> {
|
||||
center.setSpacing(8);
|
||||
center.setAlignment(Pos.CENTER_LEFT);
|
||||
|
||||
this.imageView = new ImageContainer(32);
|
||||
this.imageView = new ImageView();
|
||||
FXUtils.limitSize(imageView, 32, 32);
|
||||
|
||||
this.content = new TwoLineListItem();
|
||||
BorderPane.setAlignment(content, Pos.CENTER);
|
||||
@@ -106,26 +108,30 @@ public final class GameListCell extends ListCell<GameListItem> {
|
||||
|
||||
right.setAlignment(Pos.CENTER_RIGHT);
|
||||
|
||||
this.btnUpgrade = FXUtils.newToggleButton4(SVG.UPDATE);
|
||||
this.btnUpgrade = new JFXButton();
|
||||
btnUpgrade.setOnAction(e -> {
|
||||
GameListItem item = this.getItem();
|
||||
if (item != null)
|
||||
item.update();
|
||||
});
|
||||
btnUpgrade.getStyleClass().add("toggle-icon4");
|
||||
btnUpgrade.setGraphic(SVG.UPDATE.createIcon());
|
||||
FXUtils.installFastTooltip(btnUpgrade, i18n("version.update"));
|
||||
right.getChildren().add(btnUpgrade);
|
||||
|
||||
this.btnLaunch = FXUtils.newToggleButton4(SVG.ROCKET_LAUNCH);
|
||||
this.btnLaunch = new JFXButton();
|
||||
btnLaunch.setOnAction(e -> {
|
||||
GameListItem item = this.getItem();
|
||||
if (item != null)
|
||||
item.testGame();
|
||||
});
|
||||
btnLaunch.getStyleClass().add("toggle-icon4");
|
||||
BorderPane.setAlignment(btnLaunch, Pos.CENTER);
|
||||
btnLaunch.setGraphic(SVG.ROCKET_LAUNCH.createIcon());
|
||||
FXUtils.installFastTooltip(btnLaunch, i18n("version.launch.test"));
|
||||
right.getChildren().add(btnLaunch);
|
||||
|
||||
this.btnManage = FXUtils.newToggleButton4(SVG.MORE_VERT);
|
||||
this.btnManage = new JFXButton();
|
||||
btnManage.setOnAction(e -> {
|
||||
GameListItem item = this.getItem();
|
||||
if (item == null)
|
||||
@@ -135,7 +141,9 @@ public final class GameListCell extends ListCell<GameListItem> {
|
||||
JFXPopup.PopupVPosition vPosition = determineOptimalPopupPosition(root, popup);
|
||||
popup.show(root, vPosition, JFXPopup.PopupHPosition.RIGHT, 0, vPosition == JFXPopup.PopupVPosition.TOP ? root.getHeight() : -root.getHeight());
|
||||
});
|
||||
btnManage.getStyleClass().add("toggle-icon4");
|
||||
BorderPane.setAlignment(btnManage, Pos.CENTER);
|
||||
btnManage.setGraphic(SVG.MORE_VERT.createIcon());
|
||||
FXUtils.installFastTooltip(btnManage, i18n("settings.game.management"));
|
||||
right.getChildren().add(btnManage);
|
||||
}
|
||||
|
||||
@@ -17,34 +17,21 @@
|
||||
*/
|
||||
package org.jackhuang.hmcl.ui.versions;
|
||||
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import com.jfoenix.controls.JFXListView;
|
||||
import com.jfoenix.controls.JFXTextField;
|
||||
import javafx.animation.PauseTransition;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.property.*;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.collections.transformation.FilteredList;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.ListCell;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.control.Skin;
|
||||
import javafx.scene.control.SkinBase;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.util.Duration;
|
||||
import javafx.scene.layout.Priority;
|
||||
import javafx.scene.layout.VBox;
|
||||
import org.jackhuang.hmcl.setting.Profile;
|
||||
import org.jackhuang.hmcl.setting.Profiles;
|
||||
import org.jackhuang.hmcl.ui.*;
|
||||
import org.jackhuang.hmcl.ui.animation.ContainerAnimations;
|
||||
import org.jackhuang.hmcl.ui.animation.TransitionPane;
|
||||
import org.jackhuang.hmcl.ui.construct.AdvancedListBox;
|
||||
import org.jackhuang.hmcl.ui.construct.AdvancedListItem;
|
||||
import org.jackhuang.hmcl.ui.construct.ComponentList;
|
||||
import org.jackhuang.hmcl.ui.construct.SpinnerPane;
|
||||
import org.jackhuang.hmcl.ui.decorator.DecoratorAnimatedPage;
|
||||
import org.jackhuang.hmcl.ui.decorator.DecoratorPage;
|
||||
import org.jackhuang.hmcl.ui.profile.ProfileListItem;
|
||||
@@ -52,14 +39,9 @@ import org.jackhuang.hmcl.ui.profile.ProfilePage;
|
||||
import org.jackhuang.hmcl.util.FXThread;
|
||||
import org.jackhuang.hmcl.util.javafx.MappedObservableList;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
import static org.jackhuang.hmcl.ui.FXUtils.*;
|
||||
import static org.jackhuang.hmcl.ui.ToolbarListPageSkin.createToolbarButton2;
|
||||
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
||||
import static org.jackhuang.hmcl.util.javafx.ExtendedProperties.createSelectedItemPropertyFor;
|
||||
|
||||
@@ -78,6 +60,8 @@ public class GameListPage extends DecoratorAnimatedPage implements DecoratorPage
|
||||
});
|
||||
selectedProfile = createSelectedItemPropertyFor(profileListItems, Profile.class);
|
||||
|
||||
GameList gameList = new GameList();
|
||||
|
||||
{
|
||||
ScrollPane pane = new ScrollPane();
|
||||
VBox.setVgrow(pane, Priority.ALWAYS);
|
||||
@@ -101,12 +85,13 @@ public class GameListPage extends DecoratorAnimatedPage implements DecoratorPage
|
||||
AdvancedListBox bottomLeftCornerList = new AdvancedListBox()
|
||||
.addNavigationDrawerItem(i18n("install.new_game"), SVG.ADD_CIRCLE, Versions::addNewGame)
|
||||
.addNavigationDrawerItem(i18n("install.modpack"), SVG.PACKAGE2, Versions::importModpack)
|
||||
.addNavigationDrawerItem(i18n("button.refresh"), SVG.REFRESH, gameList::refreshList)
|
||||
.addNavigationDrawerItem(i18n("settings.type.global.manage"), SVG.SETTINGS, this::modifyGlobalGameSettings);
|
||||
FXUtils.setLimitHeight(bottomLeftCornerList, 40 * 3 + 12 * 2);
|
||||
FXUtils.setLimitHeight(bottomLeftCornerList, 40 * 4 + 12 * 2);
|
||||
setLeft(pane, bottomLeftCornerList);
|
||||
}
|
||||
|
||||
setCenter(new GameList());
|
||||
setCenter(gameList);
|
||||
}
|
||||
|
||||
public ObjectProperty<Profile> selectedProfileProperty() {
|
||||
@@ -137,12 +122,7 @@ public class GameListPage extends DecoratorAnimatedPage implements DecoratorPage
|
||||
private static class GameList extends ListPageBase<GameListItem> {
|
||||
private final WeakListenerHolder listenerHolder = new WeakListenerHolder();
|
||||
|
||||
private final ObservableList<GameListItem> sourceList = FXCollections.observableArrayList();
|
||||
private final FilteredList<GameListItem> filteredList = new FilteredList<>(sourceList);
|
||||
|
||||
public GameList() {
|
||||
setItems(filteredList);
|
||||
|
||||
Profiles.registerVersionsListener(this::loadVersions);
|
||||
|
||||
setOnFailedAction(e -> Controllers.navigate(Controllers.getDownloadPage()));
|
||||
@@ -153,125 +133,44 @@ public class GameListPage extends DecoratorAnimatedPage implements DecoratorPage
|
||||
listenerHolder.clear();
|
||||
setLoading(true);
|
||||
setFailedReason(null);
|
||||
if (profile != Profiles.getSelectedProfile())
|
||||
return;
|
||||
|
||||
List<GameListItem> versionItems = profile.getRepository().getDisplayVersions().map(instance -> new GameListItem(profile, instance.getId())).toList();
|
||||
|
||||
sourceList.setAll(versionItems);
|
||||
|
||||
if (versionItems.isEmpty()) {
|
||||
ObservableList<GameListItem> children = FXCollections.observableList(profile.getRepository().getDisplayVersions()
|
||||
.map(instance -> new GameListItem(profile, instance.getId()))
|
||||
.toList());
|
||||
setItems(children);
|
||||
if (children.isEmpty()) {
|
||||
setFailedReason(i18n("version.empty.hint"));
|
||||
}
|
||||
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
private Predicate<GameListItem> createPredicate(String searchText) {
|
||||
if (searchText == null || searchText.isEmpty()) {
|
||||
return item -> true;
|
||||
}
|
||||
|
||||
if (searchText.startsWith("regex:")) {
|
||||
String regex = searchText.substring("regex:".length());
|
||||
try {
|
||||
Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
|
||||
return item -> pattern.matcher(item.id).find();
|
||||
} catch (PatternSyntaxException e) {
|
||||
return item -> false;
|
||||
}
|
||||
} else {
|
||||
return item -> item.id.toLowerCase(Locale.ROOT).contains(searchText.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshList() {
|
||||
Profiles.getSelectedProfile().getRepository().refreshVersionsAsync().start();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Skin<?> createDefaultSkin() {
|
||||
return new GameListSkin(this);
|
||||
protected GameListSkin createDefaultSkin() {
|
||||
return new GameListSkin();
|
||||
}
|
||||
|
||||
private static class GameListSkin extends SkinBase<GameList> {
|
||||
private final TransitionPane toolbarPane;
|
||||
private final HBox searchBar;
|
||||
private final HBox toolbarNormal;
|
||||
private class GameListSkin extends ToolbarListPageSkin<GameListItem, GameList> {
|
||||
|
||||
private final JFXTextField searchField;
|
||||
|
||||
public GameListSkin(GameList skinnable) {
|
||||
super(skinnable);
|
||||
|
||||
StackPane pane = new StackPane();
|
||||
pane.setPadding(new Insets(10));
|
||||
pane.getStyleClass().addAll("notice-pane");
|
||||
|
||||
ComponentList root = new ComponentList();
|
||||
root.getStyleClass().add("no-padding");
|
||||
JFXListView<GameListItem> listView = new JFXListView<>();
|
||||
|
||||
{
|
||||
toolbarPane = new TransitionPane();
|
||||
|
||||
searchBar = new HBox();
|
||||
toolbarNormal = new HBox();
|
||||
|
||||
searchBar.setAlignment(Pos.CENTER);
|
||||
searchBar.setPadding(new Insets(0, 5, 0, 5));
|
||||
searchField = new JFXTextField();
|
||||
searchField.setPromptText(i18n("search"));
|
||||
HBox.setHgrow(searchField, Priority.ALWAYS);
|
||||
PauseTransition pause = new PauseTransition(Duration.millis(100));
|
||||
pause.setOnFinished(e -> skinnable.filteredList.setPredicate(skinnable.createPredicate(searchField.getText())));
|
||||
searchField.textProperty().addListener((observable, oldValue, newValue) -> {
|
||||
pause.setRate(1);
|
||||
pause.playFromStart();
|
||||
});
|
||||
|
||||
JFXButton closeSearchBar = createToolbarButton2(null, SVG.CLOSE, () -> {
|
||||
changeToolbar(toolbarNormal);
|
||||
searchField.clear();
|
||||
});
|
||||
|
||||
onEscPressed(searchField, closeSearchBar::fire);
|
||||
|
||||
searchBar.getChildren().setAll(searchField, closeSearchBar);
|
||||
|
||||
toolbarNormal.getChildren().setAll(createToolbarButton2(i18n("button.refresh"), SVG.REFRESH, skinnable::refreshList), createToolbarButton2(i18n("search"), SVG.SEARCH, () -> changeToolbar(searchBar)));
|
||||
|
||||
toolbarPane.setContent(toolbarNormal, ContainerAnimations.FADE);
|
||||
|
||||
root.getContent().add(toolbarPane);
|
||||
}
|
||||
|
||||
{
|
||||
SpinnerPane center = new SpinnerPane();
|
||||
ComponentList.setVgrow(center, Priority.ALWAYS);
|
||||
center.loadingProperty().bind(skinnable.loadingProperty());
|
||||
center.failedReasonProperty().bind(skinnable.failedReasonProperty());
|
||||
|
||||
listView.setCellFactory(x -> new GameListCell());
|
||||
listView.setItems(skinnable.getItems());
|
||||
|
||||
ignoreEvent(listView, KeyEvent.KEY_PRESSED, e -> e.getCode() == KeyCode.ESCAPE);
|
||||
|
||||
center.setContent(listView);
|
||||
root.getContent().add(center);
|
||||
}
|
||||
|
||||
pane.getChildren().setAll(root);
|
||||
getChildren().setAll(pane);
|
||||
public GameListSkin() {
|
||||
super(GameList.this);
|
||||
}
|
||||
|
||||
private void changeToolbar(HBox newToolbar) {
|
||||
Node oldToolbar = toolbarPane.getCurrentNode();
|
||||
if (newToolbar != oldToolbar) {
|
||||
toolbarPane.setContent(newToolbar, ContainerAnimations.FADE);
|
||||
if (newToolbar == searchBar) {
|
||||
runInFX(searchField::requestFocus);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected List<Node> initializeToolbar(GameList skinnable) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ListCell<GameListItem> createListCell(JFXListView<GameListItem> listView) {
|
||||
return new GameListCell();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import javafx.scene.Node;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ListCell;
|
||||
import javafx.scene.control.ListView;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.Region;
|
||||
@@ -37,7 +38,6 @@ import javafx.scene.layout.StackPane;
|
||||
import org.jackhuang.hmcl.game.Version;
|
||||
import org.jackhuang.hmcl.setting.Profile;
|
||||
import org.jackhuang.hmcl.ui.FXUtils;
|
||||
import org.jackhuang.hmcl.ui.construct.ImageContainer;
|
||||
import org.jackhuang.hmcl.ui.construct.RipplerContainer;
|
||||
import org.jackhuang.hmcl.ui.construct.TwoLineListItem;
|
||||
import org.jackhuang.hmcl.util.StringUtils;
|
||||
@@ -87,7 +87,7 @@ public final class GameListPopupMenu extends StackPane {
|
||||
|
||||
private final Region graphic;
|
||||
|
||||
private final ImageContainer imageView;
|
||||
private final ImageView imageView;
|
||||
private final TwoLineListItem content;
|
||||
|
||||
private final StringProperty tag = new SimpleStringProperty();
|
||||
@@ -103,7 +103,8 @@ public final class GameListPopupMenu extends StackPane {
|
||||
FXUtils.setLimitWidth(imageViewContainer, 32);
|
||||
FXUtils.setLimitHeight(imageViewContainer, 32);
|
||||
|
||||
this.imageView = new ImageContainer(32);
|
||||
this.imageView = new ImageView();
|
||||
FXUtils.limitSize(imageView, 32, 32);
|
||||
imageViewContainer.getChildren().setAll(imageView);
|
||||
|
||||
this.content = new TwoLineListItem();
|
||||
|
||||
+1
-3
@@ -50,9 +50,7 @@ public final class HMCLLocalizedDownloadListPage extends DownloadListPage {
|
||||
}
|
||||
|
||||
public static DownloadListPage ofShaderPack(DownloadPage.DownloadCallback callback, boolean versionSelection) {
|
||||
var page = new HMCLLocalizedDownloadListPage(callback, versionSelection, RemoteModRepository.Type.SHADER_PACK, null, ModrinthRemoteModRepository.SHADER_PACKS);
|
||||
page.supportChinese.set(false);
|
||||
return page;
|
||||
return new HMCLLocalizedDownloadListPage(callback, versionSelection, RemoteModRepository.Type.SHADER_PACK, null, ModrinthRemoteModRepository.SHADER_PACKS);
|
||||
}
|
||||
|
||||
private HMCLLocalizedDownloadListPage(DownloadPage.DownloadCallback callback, boolean versionSelection, RemoteModRepository.Type type, CurseForgeRemoteModRepository curseForge, ModrinthRemoteModRepository modrinth) {
|
||||
|
||||
@@ -43,7 +43,6 @@ import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
@@ -245,7 +244,6 @@ public final class ModListPage extends ListPageBase<ModListPageSkin.ModInfoObjec
|
||||
return null;
|
||||
})
|
||||
.whenComplete(Schedulers.javafx(), (result, exception) -> {
|
||||
if (exception instanceof CancellationException) return;
|
||||
if (exception != null || result == null) {
|
||||
Controllers.dialog(i18n("mods.check_updates.failed_check"), i18n("message.failed"), MessageDialogPane.MessageType.ERROR);
|
||||
} else if (result.isEmpty()) {
|
||||
@@ -254,7 +252,7 @@ public final class ModListPage extends ListPageBase<ModListPageSkin.ModInfoObjec
|
||||
Controllers.navigateForward(new ModUpdatesPage(modManager, result));
|
||||
}
|
||||
})
|
||||
.withStagesHints("update.checking"),
|
||||
.withStagesHint(Collections.singletonList("update.checking")),
|
||||
i18n("mods.check_updates"), TaskCancellationAction.NORMAL);
|
||||
|
||||
if (profile.getRepository().isModpack(instanceId)) {
|
||||
|
||||
@@ -30,6 +30,7 @@ import javafx.geometry.Pos;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.layout.HBox;
|
||||
@@ -376,20 +377,20 @@ final class ModListPageSkin extends SkinBase<ModListPage> {
|
||||
return VersionIconType.getIconType(this.localModFile.getModLoaderType()).getIcon();
|
||||
}
|
||||
|
||||
public void loadIcon(ImageContainer imageContainer, @Nullable WeakReference<ObjectProperty<ModInfoObject>> current) {
|
||||
public void loadIcon(ImageView imageView, @Nullable WeakReference<ObjectProperty<ModInfoObject>> current) {
|
||||
SoftReference<CompletableFuture<Image>> iconCache = this.iconCache;
|
||||
CompletableFuture<Image> imageFuture;
|
||||
if (iconCache != null && (imageFuture = iconCache.get()) != null) {
|
||||
Image image = imageFuture.getNow(null);
|
||||
if (image != null) {
|
||||
imageContainer.setImage(image);
|
||||
imageView.setImage(image);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
imageFuture = CompletableFuture.supplyAsync(this::loadIcon, Schedulers.io());
|
||||
this.iconCache = new SoftReference<>(imageFuture);
|
||||
}
|
||||
imageContainer.setImage(VersionIconType.getIconType(localModFile.getModLoaderType()).getIcon());
|
||||
imageView.setImage(VersionIconType.getIconType(localModFile.getModLoaderType()).getIcon());
|
||||
imageFuture.thenAcceptAsync(image -> {
|
||||
if (current != null) {
|
||||
ObjectProperty<ModInfoObject> infoObjectProperty = current.get();
|
||||
@@ -399,7 +400,7 @@ final class ModListPageSkin extends SkinBase<ModListPage> {
|
||||
}
|
||||
}
|
||||
|
||||
imageContainer.setImage(image);
|
||||
imageView.setImage(image);
|
||||
}, Schedulers.javafx());
|
||||
}
|
||||
}
|
||||
@@ -413,8 +414,9 @@ final class ModListPageSkin extends SkinBase<ModListPage> {
|
||||
Stage stage = Controllers.getStage();
|
||||
maxWidthProperty().bind(stage.widthProperty().multiply(0.7));
|
||||
|
||||
var imageContainer = new ImageContainer(40);
|
||||
modInfo.loadIcon(imageContainer, null);
|
||||
ImageView imageView = new ImageView();
|
||||
FXUtils.limitSize(imageView, 40, 40);
|
||||
modInfo.loadIcon(imageView, null);
|
||||
|
||||
TwoLineListItem title = new TwoLineListItem();
|
||||
if (modInfo.getModTranslations() != null && I18n.isUseChinese())
|
||||
@@ -435,7 +437,7 @@ final class ModListPageSkin extends SkinBase<ModListPage> {
|
||||
}
|
||||
title.setSubtitle(subtitle.toString());
|
||||
|
||||
titleContainer.getChildren().setAll(imageContainer, title);
|
||||
titleContainer.getChildren().setAll(FXUtils.limitingSize(imageView, 40, 40), title);
|
||||
setHeading(titleContainer);
|
||||
|
||||
Label description = new Label(modInfo.getModInfo().getDescription().toString());
|
||||
@@ -552,11 +554,11 @@ final class ModListPageSkin extends SkinBase<ModListPage> {
|
||||
private static final PseudoClass WARNING = PseudoClass.getPseudoClass("warning");
|
||||
|
||||
JFXCheckBox checkBox = new JFXCheckBox();
|
||||
ImageContainer imageContainer = new ImageContainer(24);
|
||||
ImageView imageView = new ImageView();
|
||||
TwoLineListItem content = new TwoLineListItem();
|
||||
JFXButton restoreButton = FXUtils.newToggleButton4(SVG.RESTORE);
|
||||
JFXButton infoButton = FXUtils.newToggleButton4(SVG.INFO);
|
||||
JFXButton revealButton = FXUtils.newToggleButton4(SVG.FOLDER);
|
||||
JFXButton restoreButton = new JFXButton();
|
||||
JFXButton infoButton = new JFXButton();
|
||||
JFXButton revealButton = new JFXButton();
|
||||
BooleanProperty booleanProperty;
|
||||
|
||||
Tooltip warningTooltip;
|
||||
@@ -573,11 +575,23 @@ final class ModListPageSkin extends SkinBase<ModListPage> {
|
||||
content.setMouseTransparent(true);
|
||||
setSelectable();
|
||||
|
||||
imageContainer.setImage(VersionIconType.COMMAND.getIcon());
|
||||
imageView.setFitWidth(24);
|
||||
imageView.setFitHeight(24);
|
||||
imageView.setPreserveRatio(true);
|
||||
imageView.setImage(VersionIconType.COMMAND.getIcon());
|
||||
|
||||
restoreButton.getStyleClass().add("toggle-icon4");
|
||||
restoreButton.setGraphic(SVG.RESTORE.createIcon());
|
||||
|
||||
FXUtils.installFastTooltip(restoreButton, i18n("mods.restore"));
|
||||
|
||||
container.getChildren().setAll(checkBox, imageContainer, content, restoreButton, revealButton, infoButton);
|
||||
revealButton.getStyleClass().add("toggle-icon4");
|
||||
revealButton.setGraphic(SVG.FOLDER.createIcon());
|
||||
|
||||
infoButton.getStyleClass().add("toggle-icon4");
|
||||
infoButton.setGraphic(SVG.INFO.createIcon());
|
||||
|
||||
container.getChildren().setAll(checkBox, imageView, content, restoreButton, revealButton, infoButton);
|
||||
|
||||
StackPane.setMargin(container, new Insets(8));
|
||||
getContainer().getChildren().setAll(container);
|
||||
@@ -602,7 +616,7 @@ final class ModListPageSkin extends SkinBase<ModListPage> {
|
||||
|
||||
ModLoaderType modLoaderType = modInfo.getModLoaderType();
|
||||
|
||||
dataItem.loadIcon(imageContainer, new WeakReference<>(this.itemProperty()));
|
||||
dataItem.loadIcon(imageView, new WeakReference<>(this.itemProperty()));
|
||||
|
||||
String displayName = modInfo.getName();
|
||||
if (modTranslations != null && I18n.isUseChinese()) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import javafx.scene.Node;
|
||||
import javafx.scene.control.ListCell;
|
||||
import javafx.scene.control.Skin;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.Priority;
|
||||
@@ -18,7 +19,10 @@ import org.jackhuang.hmcl.setting.Profile;
|
||||
import org.jackhuang.hmcl.task.Schedulers;
|
||||
import org.jackhuang.hmcl.task.Task;
|
||||
import org.jackhuang.hmcl.ui.*;
|
||||
import org.jackhuang.hmcl.ui.construct.*;
|
||||
import org.jackhuang.hmcl.ui.construct.MDListCell;
|
||||
import org.jackhuang.hmcl.ui.construct.MessageDialogPane;
|
||||
import org.jackhuang.hmcl.ui.construct.RipplerContainer;
|
||||
import org.jackhuang.hmcl.ui.construct.TwoLineListItem;
|
||||
import org.jackhuang.hmcl.util.io.FileUtils;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
@@ -177,10 +181,10 @@ public final class ResourcepackListPage extends ListPageBase<ResourcepackListPag
|
||||
}
|
||||
|
||||
private static final class ResourcepackListCell extends MDListCell<ResourcepackInfoObject> {
|
||||
private final ImageContainer imageView = new ImageContainer(32);
|
||||
private final ImageView imageView = new ImageView();
|
||||
private final TwoLineListItem content = new TwoLineListItem();
|
||||
private final JFXButton btnReveal = FXUtils.newToggleButton4(SVG.FOLDER_OPEN);
|
||||
private final JFXButton btnDelete = FXUtils.newToggleButton4(SVG.DELETE_FOREVER);
|
||||
private final JFXButton btnReveal = new JFXButton();
|
||||
private final JFXButton btnDelete = new JFXButton();
|
||||
private final ResourcepackListPage page;
|
||||
|
||||
public ResourcepackListCell(JFXListView<ResourcepackInfoObject> listView, ResourcepackListPage page) {
|
||||
@@ -194,6 +198,7 @@ public final class ResourcepackListPage extends ListPageBase<ResourcepackListPag
|
||||
|
||||
HBox left = new HBox(8);
|
||||
left.setAlignment(Pos.CENTER);
|
||||
FXUtils.limitSize(imageView, 32, 32);
|
||||
left.getChildren().add(imageView);
|
||||
left.setPadding(new Insets(0, 8, 0, 0));
|
||||
FXUtils.setLimitWidth(left, 48);
|
||||
@@ -202,6 +207,12 @@ public final class ResourcepackListPage extends ListPageBase<ResourcepackListPag
|
||||
HBox.setHgrow(content, Priority.ALWAYS);
|
||||
root.setCenter(content);
|
||||
|
||||
btnReveal.getStyleClass().add("toggle-icon4");
|
||||
btnReveal.setGraphic(SVG.FOLDER_OPEN.createIcon());
|
||||
|
||||
btnDelete.getStyleClass().add("toggle-icon4");
|
||||
btnDelete.setGraphic(SVG.DELETE_FOREVER.createIcon());
|
||||
|
||||
HBox right = new HBox(8);
|
||||
right.setAlignment(Pos.CENTER_RIGHT);
|
||||
right.getChildren().setAll(btnReveal, btnDelete);
|
||||
|
||||
@@ -25,6 +25,7 @@ import javafx.geometry.Pos;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.image.PixelWriter;
|
||||
import javafx.scene.image.WritableImage;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
@@ -441,7 +442,9 @@ public final class SchematicsPage extends ListPageBase<SchematicsPage.Item> impl
|
||||
if (image == null) {
|
||||
return super.getIcon(size);
|
||||
} else {
|
||||
var imageView = new ImageContainer(size);
|
||||
ImageView imageView = new ImageView();
|
||||
imageView.setFitHeight(size);
|
||||
imageView.setFitWidth(size);
|
||||
imageView.setImage(image);
|
||||
return imageView;
|
||||
}
|
||||
@@ -545,7 +548,7 @@ public final class SchematicsPage extends ListPageBase<SchematicsPage.Item> impl
|
||||
private final TwoLineListItem center;
|
||||
private final HBox right;
|
||||
|
||||
private final ImageContainer iconImageView;
|
||||
private final ImageView iconImageView;
|
||||
private final SVGContainer iconSVGView;
|
||||
|
||||
private final Tooltip tooltip = new Tooltip();
|
||||
@@ -559,7 +562,9 @@ public final class SchematicsPage extends ListPageBase<SchematicsPage.Item> impl
|
||||
this.left = new StackPane();
|
||||
left.setPadding(new Insets(0, 8, 0, 0));
|
||||
|
||||
this.iconImageView = new ImageContainer(32);
|
||||
this.iconImageView = new ImageView();
|
||||
FXUtils.limitSize(iconImageView, 32, 32);
|
||||
|
||||
this.iconSVGView = new SVGContainer(32);
|
||||
|
||||
BorderPane.setAlignment(left, Pos.CENTER);
|
||||
@@ -575,15 +580,19 @@ public final class SchematicsPage extends ListPageBase<SchematicsPage.Item> impl
|
||||
this.right = new HBox(8);
|
||||
right.setAlignment(Pos.CENTER_RIGHT);
|
||||
|
||||
JFXButton btnReveal = FXUtils.newToggleButton4(SVG.FOLDER_OPEN);
|
||||
JFXButton btnReveal = new JFXButton();
|
||||
FXUtils.installFastTooltip(btnReveal, i18n("reveal.in_file_manager"));
|
||||
btnReveal.getStyleClass().add("toggle-icon4");
|
||||
btnReveal.setGraphic(SVG.FOLDER_OPEN.createIcon());
|
||||
btnReveal.setOnAction(event -> {
|
||||
Item item = getItem();
|
||||
if (item != null && !(item instanceof BackItem))
|
||||
item.onReveal();
|
||||
});
|
||||
|
||||
JFXButton btnDelete = FXUtils.newToggleButton4(SVG.DELETE_FOREVER);
|
||||
JFXButton btnDelete = new JFXButton();
|
||||
btnDelete.getStyleClass().add("toggle-icon4");
|
||||
btnDelete.setGraphic(SVG.DELETE_FOREVER.createIcon());
|
||||
btnDelete.setOnAction(event -> {
|
||||
Item item = getItem();
|
||||
if (item != null && !(item instanceof BackItem)) {
|
||||
|
||||
@@ -21,8 +21,6 @@ import com.jfoenix.controls.JFXPopup;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.property.*;
|
||||
import javafx.event.Event;
|
||||
import javafx.event.EventType;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.layout.Priority;
|
||||
import javafx.scene.layout.VBox;
|
||||
@@ -63,13 +61,6 @@ public class VersionPage extends DecoratorAnimatedPage implements DecoratorPage
|
||||
|
||||
private String preferredVersionName = null;
|
||||
|
||||
public static class WorkingDirChangedEvent extends Event {
|
||||
public static final EventType<WorkingDirChangedEvent> EVENT_TYPE = new EventType<>(Event.ANY, "WORKING_DIR_CHANGED");
|
||||
public WorkingDirChangedEvent() {
|
||||
super(EVENT_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
public VersionPage() {
|
||||
versionSettingsTab.setNodeSupplier(loadVersionFor(() -> new VersionSettingsPage(false)));
|
||||
installerListTab.setNodeSupplier(loadVersionFor(InstallerListPage::new));
|
||||
@@ -83,21 +74,6 @@ public class VersionPage extends DecoratorAnimatedPage implements DecoratorPage
|
||||
|
||||
addEventHandler(Navigator.NavigationEvent.NAVIGATED, this::onNavigated);
|
||||
|
||||
addEventHandler(WorkingDirChangedEvent.EVENT_TYPE, event -> {
|
||||
if (this.version.get() != null) {
|
||||
if (installerListTab.isInitialized())
|
||||
installerListTab.getNode().loadVersion(getProfile(), getVersion());
|
||||
if (modListTab.isInitialized())
|
||||
modListTab.getNode().loadVersion(getProfile(), getVersion());
|
||||
if (resourcePackTab.isInitialized())
|
||||
resourcePackTab.getNode().loadVersion(getProfile(), getVersion());
|
||||
if (worldListTab.isInitialized())
|
||||
worldListTab.getNode().loadVersion(getProfile(), getVersion());
|
||||
if (schematicsTab.isInitialized())
|
||||
schematicsTab.getNode().loadVersion(getProfile(), getVersion());
|
||||
}
|
||||
});
|
||||
|
||||
listenerHolder.add(EventBus.EVENT_BUS.channel(RefreshedVersionsEvent.class).registerWeak(event -> checkSelectedVersion(), EventPriority.HIGHEST));
|
||||
}
|
||||
|
||||
|
||||
@@ -34,12 +34,8 @@ import javafx.scene.layout.*;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.stage.FileChooser;
|
||||
import javafx.stage.Screen;
|
||||
import org.jackhuang.hmcl.game.GameDirectoryType;
|
||||
import org.jackhuang.hmcl.game.HMCLGameRepository;
|
||||
import org.jackhuang.hmcl.game.ProcessPriority;
|
||||
import org.jackhuang.hmcl.game.Version;
|
||||
import org.jackhuang.hmcl.game.*;
|
||||
import org.jackhuang.hmcl.java.JavaManager;
|
||||
import org.jackhuang.hmcl.java.JavaRuntime;
|
||||
import org.jackhuang.hmcl.setting.*;
|
||||
import org.jackhuang.hmcl.ui.Controllers;
|
||||
import org.jackhuang.hmcl.ui.FXUtils;
|
||||
@@ -52,6 +48,7 @@ import org.jackhuang.hmcl.util.javafx.BindingMapping;
|
||||
import org.jackhuang.hmcl.util.javafx.PropertyUtils;
|
||||
import org.jackhuang.hmcl.util.javafx.SafeStringConverter;
|
||||
import org.jackhuang.hmcl.util.platform.Architecture;
|
||||
import org.jackhuang.hmcl.java.JavaRuntime;
|
||||
import org.jackhuang.hmcl.util.platform.OperatingSystem;
|
||||
import org.jackhuang.hmcl.util.platform.SystemInfo;
|
||||
import org.jackhuang.hmcl.util.platform.hardware.PhysicalMemoryStatus;
|
||||
@@ -102,10 +99,6 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag
|
||||
private final InvalidationListener usesGlobalListener;
|
||||
private final ChangeListener<Boolean> specificSettingsListener;
|
||||
private final InvalidationListener javaListener = any -> initJavaSubtitle();
|
||||
|
||||
private final ChangeListener<GameDirectoryType> gameDirTypeListener = (ob, o, n) -> fireWorkingDirChanged();
|
||||
private final ChangeListener<String> gameDirListener = (ob, o, n) -> fireWorkingDirChanged();
|
||||
|
||||
private boolean updatingJavaSetting = false;
|
||||
private boolean updatingSelectedJava = false;
|
||||
|
||||
@@ -462,20 +455,13 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag
|
||||
else
|
||||
profile.getRepository().globalizeVersionSetting(versionId);
|
||||
|
||||
FXUtils.runInFX(() -> {
|
||||
loadVersion(profile, versionId);
|
||||
fireWorkingDirChanged();
|
||||
});
|
||||
Platform.runLater(() -> loadVersion(profile, versionId));
|
||||
};
|
||||
|
||||
addEventHandler(Navigator.NavigationEvent.NAVIGATED, this::onDecoratorPageNavigating);
|
||||
|
||||
componentList.disableProperty().bind(enableSpecificSettings.not());
|
||||
}
|
||||
|
||||
private void fireWorkingDirChanged() {
|
||||
FXUtils.runInFX(() -> fireEvent(new VersionPage.WorkingDirChangedEvent()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadVersion(Profile profile, String versionId) {
|
||||
@@ -527,9 +513,6 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag
|
||||
lastVersionSetting.defaultJavaPathPropertyProperty().removeListener(javaListener);
|
||||
lastVersionSetting.javaVersionProperty().removeListener(javaListener);
|
||||
|
||||
lastVersionSetting.gameDirTypeProperty().removeListener(gameDirTypeListener);
|
||||
lastVersionSetting.gameDirProperty().removeListener(gameDirListener);
|
||||
|
||||
gameDirItem.selectedDataProperty().unbindBidirectional(lastVersionSetting.gameDirTypeProperty());
|
||||
gameDirSublist.subtitleProperty().unbind();
|
||||
|
||||
@@ -606,9 +589,6 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag
|
||||
gameDirSublist.subtitleProperty().bind(Bindings.createStringBinding(() -> profile.getRepository().getRunDirectory(versionId).toAbsolutePath().normalize().toString(),
|
||||
versionSetting.gameDirProperty(), versionSetting.gameDirTypeProperty()));
|
||||
|
||||
versionSetting.gameDirTypeProperty().addListener(gameDirTypeListener);
|
||||
versionSetting.gameDirProperty().addListener(gameDirListener);
|
||||
|
||||
lastVersionSetting = versionSetting;
|
||||
|
||||
initJavaSubtitle();
|
||||
@@ -747,6 +727,7 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag
|
||||
}
|
||||
|
||||
iconPickerItem.setImage(profile.getRepository().getVersionIconImage(versionId));
|
||||
FXUtils.limitSize(iconPickerItem.getImageView(), 32, 32);
|
||||
}
|
||||
|
||||
private static List<String> getSupportedResolutions() {
|
||||
|
||||
@@ -26,6 +26,7 @@ import javafx.scene.Node;
|
||||
import javafx.scene.control.Control;
|
||||
import javafx.scene.control.Skin;
|
||||
import javafx.scene.control.SkinBase;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.StackPane;
|
||||
@@ -34,7 +35,6 @@ import org.jackhuang.hmcl.game.WorldLockedException;
|
||||
import org.jackhuang.hmcl.task.Schedulers;
|
||||
import org.jackhuang.hmcl.task.Task;
|
||||
import org.jackhuang.hmcl.ui.*;
|
||||
import org.jackhuang.hmcl.ui.construct.ImageContainer;
|
||||
import org.jackhuang.hmcl.ui.construct.MessageDialogPane;
|
||||
import org.jackhuang.hmcl.ui.construct.RipplerContainer;
|
||||
import org.jackhuang.hmcl.ui.construct.TwoLineListItem;
|
||||
@@ -232,8 +232,9 @@ public final class WorldBackupsPage extends ListPageBase<WorldBackupsPage.Backup
|
||||
root.setLeft(left);
|
||||
left.setPadding(new Insets(0, 8, 0, 0));
|
||||
|
||||
var imageView = new ImageContainer(32);
|
||||
ImageView imageView = new ImageView();
|
||||
left.getChildren().add(imageView);
|
||||
FXUtils.limitSize(imageView, 32, 32);
|
||||
imageView.setImage(world.getIcon() == null ? FXUtils.newBuiltinImage("/assets/img/unknown_server.png") : world.getIcon());
|
||||
}
|
||||
|
||||
@@ -254,14 +255,18 @@ public final class WorldBackupsPage extends ListPageBase<WorldBackupsPage.Backup
|
||||
root.setRight(right);
|
||||
right.setAlignment(Pos.CENTER_RIGHT);
|
||||
|
||||
JFXButton btnReveal = FXUtils.newToggleButton4(SVG.FOLDER_OPEN);
|
||||
JFXButton btnReveal = new JFXButton();
|
||||
right.getChildren().add(btnReveal);
|
||||
FXUtils.installFastTooltip(btnReveal, i18n("reveal.in_file_manager"));
|
||||
btnReveal.getStyleClass().add("toggle-icon4");
|
||||
btnReveal.setGraphic(SVG.FOLDER_OPEN.createIcon());
|
||||
btnReveal.setOnAction(event -> skinnable.onReveal());
|
||||
|
||||
JFXButton btnDelete = FXUtils.newToggleButton4(SVG.DELETE);
|
||||
JFXButton btnDelete = new JFXButton();
|
||||
right.getChildren().add(btnDelete);
|
||||
FXUtils.installFastTooltip(btnDelete, i18n("world.backup.delete"));
|
||||
btnDelete.getStyleClass().add("toggle-icon4");
|
||||
btnDelete.setGraphic(SVG.DELETE.createIcon());
|
||||
btnDelete.setOnAction(event -> Controllers.confirm(i18n("button.remove.confirm"), i18n("button.remove"), skinnable::onDelete, null));
|
||||
}
|
||||
|
||||
|
||||
@@ -30,11 +30,14 @@ import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.effect.BoxBlur;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.FileChooser;
|
||||
import org.jackhuang.hmcl.game.World;
|
||||
import org.jackhuang.hmcl.task.Schedulers;
|
||||
import org.jackhuang.hmcl.task.Task;
|
||||
import org.jackhuang.hmcl.ui.Controllers;
|
||||
import org.jackhuang.hmcl.ui.FXUtils;
|
||||
import org.jackhuang.hmcl.ui.SVG;
|
||||
@@ -64,10 +67,9 @@ public final class WorldInfoPage extends SpinnerPane implements WorldManagePage.
|
||||
private final WorldManagePage worldManagePage;
|
||||
private boolean isReadOnly;
|
||||
private final World world;
|
||||
private CompoundTag levelData;
|
||||
private CompoundTag playerData;
|
||||
private CompoundTag levelDat;
|
||||
|
||||
private final ImageContainer iconImageView = new ImageContainer(32);
|
||||
ImageView iconImageView = new ImageView();
|
||||
|
||||
public WorldInfoPage(WorldManagePage worldManagePage) {
|
||||
this.worldManagePage = worldManagePage;
|
||||
@@ -75,9 +77,15 @@ public final class WorldInfoPage extends SpinnerPane implements WorldManagePage.
|
||||
refresh();
|
||||
}
|
||||
|
||||
private CompoundTag loadWorldInfo() throws IOException {
|
||||
if (!Files.isDirectory(world.getFile()))
|
||||
throw new IOException("Not a valid world directory");
|
||||
|
||||
return world.getLevelData();
|
||||
}
|
||||
|
||||
private void updateControls() {
|
||||
CompoundTag dataTag = levelData.get("Data");
|
||||
CompoundTag playerTag = playerData;
|
||||
CompoundTag dataTag = levelDat.get("Data");
|
||||
|
||||
ScrollPane scrollPane = new ScrollPane();
|
||||
scrollPane.setFitToHeight(true);
|
||||
@@ -129,12 +137,14 @@ public final class WorldInfoPage extends SpinnerPane implements WorldManagePage.
|
||||
iconPane.setTitle(i18n("world.icon"));
|
||||
|
||||
{
|
||||
FXUtils.limitSize(iconImageView, 32, 32);
|
||||
iconImageView.setImage(world.getIcon() == null ? FXUtils.newBuiltinImage("/assets/img/unknown_server.png") : world.getIcon());
|
||||
}
|
||||
|
||||
JFXButton editIconButton = FXUtils.newToggleButton4(SVG.EDIT, 20);
|
||||
JFXButton resetIconButton = FXUtils.newToggleButton4(SVG.RESTORE, 20);
|
||||
JFXButton editIconButton = new JFXButton();
|
||||
JFXButton resetIconButton = new JFXButton();
|
||||
{
|
||||
editIconButton.setGraphic(SVG.EDIT.createIcon(20));
|
||||
editIconButton.setDisable(isReadOnly);
|
||||
editIconButton.setOnAction(event -> Controllers.confirm(
|
||||
I18n.i18n("world.icon.change.tip"),
|
||||
@@ -144,10 +154,13 @@ public final class WorldInfoPage extends SpinnerPane implements WorldManagePage.
|
||||
null
|
||||
));
|
||||
FXUtils.installFastTooltip(editIconButton, i18n("button.edit"));
|
||||
editIconButton.getStyleClass().add("toggle-icon4");
|
||||
|
||||
resetIconButton.setGraphic(SVG.RESTORE.createIcon(20));
|
||||
resetIconButton.setDisable(isReadOnly);
|
||||
resetIconButton.setOnAction(event -> this.clearWorldIcon());
|
||||
FXUtils.installFastTooltip(resetIconButton, i18n("button.reset"));
|
||||
resetIconButton.getStyleClass().add("toggle-icon4");
|
||||
}
|
||||
|
||||
HBox hBox = new HBox(8);
|
||||
@@ -198,14 +211,12 @@ public final class WorldInfoPage extends SpinnerPane implements WorldManagePage.
|
||||
worldSpawnPoint.setTitle(i18n("world.info.spawn"));
|
||||
|
||||
String value;
|
||||
// Valid after 1.21.9-pre1
|
||||
if (dataTag.get("spawn") instanceof CompoundTag spawnTag && spawnTag.get("pos") instanceof IntArrayTag posTag) {
|
||||
value = (spawnTag.get("dimension") instanceof StringTag dimensionTag)
|
||||
? Dimension.of(dimensionTag).formatPosition(posTag)
|
||||
: Dimension.OVERWORLD.formatPosition(posTag);
|
||||
}
|
||||
// Valid before 1.21.9-pre1
|
||||
else if (dataTag.get("SpawnX") instanceof IntTag intX
|
||||
value = Dimension.of(spawnTag.get("dimension") instanceof StringTag dimensionTag
|
||||
? dimensionTag
|
||||
: new StringTag("SpawnDimension", "minecraft:overworld"))
|
||||
.formatPosition(posTag);
|
||||
} else if (dataTag.get("SpawnX") instanceof IntTag intX
|
||||
&& dataTag.get("SpawnY") instanceof IntTag intY
|
||||
&& dataTag.get("SpawnZ") instanceof IntTag intZ) {
|
||||
value = Dimension.OVERWORLD.formatPosition(intX.getValue(), intY.getValue(), intZ.getValue());
|
||||
@@ -243,51 +254,34 @@ public final class WorldInfoPage extends SpinnerPane implements WorldManagePage.
|
||||
{
|
||||
generateFeaturesButton.setTitle(i18n("world.info.generate_features"));
|
||||
generateFeaturesButton.setDisable(isReadOnly);
|
||||
// Valid before (1.16)20w20a
|
||||
if (dataTag.get("MapFeatures") instanceof ByteTag generateFeaturesTag) {
|
||||
bindTagAndToggleButton(generateFeaturesTag, generateFeaturesButton);
|
||||
}
|
||||
// Valid after (1.16)20w20a
|
||||
else if (world.getNormalizedWorldGenSettingsData() != null) {
|
||||
CompoundTag unifiedWorldGenSettingsDataTag = world.getNormalizedWorldGenSettingsData();
|
||||
Tag tag = unifiedWorldGenSettingsDataTag.get("generate_features"); // Valid between (1.16)20w20a and 26.1-snapshot-6
|
||||
if (tag == null)
|
||||
tag = unifiedWorldGenSettingsDataTag.get("generate_structures"); // Valid after 26.1-snapshot-6
|
||||
bindTagAndToggleButton(tag, generateFeaturesButton);
|
||||
|
||||
// generate_features was valid after 20w20a and MapFeatures was before that
|
||||
if (dataTag.get("WorldGenSettings") instanceof CompoundTag worldGenSettings) {
|
||||
bindTagAndToggleButton(worldGenSettings.get("generate_features"), generateFeaturesButton);
|
||||
} else {
|
||||
generateFeaturesButton.setDisable(true);
|
||||
bindTagAndToggleButton(dataTag.get("MapFeatures"), generateFeaturesButton);
|
||||
}
|
||||
}
|
||||
|
||||
var difficultyButton = new LineSelectButton<Difficulty>();
|
||||
{
|
||||
difficultyButton.setTitle(i18n("world.info.difficulty"));
|
||||
difficultyButton.setDisable(isReadOnly);
|
||||
difficultyButton.setDisable(worldManagePage.isReadOnly());
|
||||
difficultyButton.setItems(Difficulty.items);
|
||||
|
||||
Difficulty difficulty;
|
||||
// Valid before 26.1-snapshot-6
|
||||
if (dataTag.get("Difficulty") instanceof ByteTag difficultyTag
|
||||
&& (difficulty = Difficulty.of(difficultyTag.getValue())) != null) {
|
||||
difficultyButton.setValue(difficulty);
|
||||
difficultyButton.valueProperty().addListener((o, oldValue, newValue) -> {
|
||||
if (newValue != null) {
|
||||
difficultyTag.setValue((byte) newValue.ordinal());
|
||||
saveWorldData();
|
||||
}
|
||||
});
|
||||
}
|
||||
// Valid after 26.1-snapshot-6
|
||||
else if (dataTag.get("difficulty_settings") instanceof CompoundTag difficultySettingTag
|
||||
&& difficultySettingTag.get("difficulty") instanceof StringTag difficultyTag
|
||||
&& (difficulty = Difficulty.of(difficultyTag.getValue())) != null) {
|
||||
difficultyButton.setValue(difficulty);
|
||||
difficultyButton.valueProperty().addListener((o, oldValue, newValue) -> {
|
||||
if (newValue != null) {
|
||||
difficultyTag.setValue(newValue.getTagStringValue());
|
||||
saveWorldData();
|
||||
}
|
||||
});
|
||||
if (dataTag.get("Difficulty") instanceof ByteTag difficultyTag) {
|
||||
Difficulty difficulty = Difficulty.of(difficultyTag.getValue());
|
||||
if (difficulty != null) {
|
||||
difficultyButton.setValue(difficulty);
|
||||
difficultyButton.valueProperty().addListener((o, oldValue, newValue) -> {
|
||||
if (newValue != null) {
|
||||
difficultyTag.setValue((byte) newValue.ordinal());
|
||||
saveLevelDat();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
difficultyButton.setDisable(true);
|
||||
}
|
||||
} else {
|
||||
difficultyButton.setDisable(true);
|
||||
}
|
||||
@@ -297,17 +291,8 @@ public final class WorldInfoPage extends SpinnerPane implements WorldManagePage.
|
||||
{
|
||||
difficultyLockPane.setTitle(i18n("world.info.difficulty_lock"));
|
||||
difficultyLockPane.setDisable(isReadOnly);
|
||||
// Valid before 26.1-snapshot-6
|
||||
if (dataTag.get("DifficultyLocked") instanceof ByteTag difficultyLockedTag) {
|
||||
bindTagAndToggleButton(difficultyLockedTag, difficultyLockPane);
|
||||
}
|
||||
// Valid after 26.1-snapshot-6
|
||||
else if (dataTag.get("difficulty_settings") instanceof CompoundTag difficultySettingTag
|
||||
&& difficultySettingTag.get("locked") instanceof ByteTag lockedTag) {
|
||||
bindTagAndToggleButton(lockedTag, difficultyLockPane);
|
||||
} else {
|
||||
difficultyLockPane.setDisable(true);
|
||||
}
|
||||
|
||||
bindTagAndToggleButton(dataTag.get("DifficultyLocked"), difficultyLockPane);
|
||||
}
|
||||
|
||||
worldInfo.getContent().setAll(
|
||||
@@ -317,7 +302,7 @@ public final class WorldInfoPage extends SpinnerPane implements WorldManagePage.
|
||||
rootPane.getChildren().addAll(ComponentList.createComponentListTitle(i18n("world.info")), worldInfo);
|
||||
}
|
||||
|
||||
if (playerTag != null) {
|
||||
if (dataTag.get("Player") instanceof CompoundTag playerTag) {
|
||||
ComponentList playerInfo = new ComponentList();
|
||||
|
||||
var locationPane = new LineTextPane();
|
||||
@@ -364,14 +349,8 @@ public final class WorldInfoPage extends SpinnerPane implements WorldManagePage.
|
||||
playerGameTypePane.setDisable(worldManagePage.isReadOnly());
|
||||
playerGameTypePane.setItems(GameType.items);
|
||||
|
||||
// Valid before 26.1-snapshot-6
|
||||
Tag rawHardcoreTag = dataTag.get("hardcore");
|
||||
// Valid after 26.1-snapshot-6
|
||||
if (rawHardcoreTag == null && dataTag.get("difficulty_settings") instanceof CompoundTag difficultySettingsTag) {
|
||||
rawHardcoreTag = difficultySettingsTag.get("hardcore");
|
||||
}
|
||||
|
||||
if (playerTag.get("playerGameType") instanceof IntTag playerGameTypeTag && rawHardcoreTag instanceof ByteTag hardcoreTag) {
|
||||
if (playerTag.get("playerGameType") instanceof IntTag playerGameTypeTag
|
||||
&& dataTag.get("hardcore") instanceof ByteTag hardcoreTag) {
|
||||
boolean isHardcore = hardcoreTag.getValue() == 1;
|
||||
GameType gameType = GameType.of(playerGameTypeTag.getValue(), isHardcore);
|
||||
if (gameType != null) {
|
||||
@@ -385,7 +364,7 @@ public final class WorldInfoPage extends SpinnerPane implements WorldManagePage.
|
||||
playerGameTypeTag.setValue(newValue.ordinal());
|
||||
hardcoreTag.setValue((byte) 0);
|
||||
}
|
||||
saveWorldData();
|
||||
saveLevelDat();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -455,10 +434,10 @@ public final class WorldInfoPage extends SpinnerPane implements WorldManagePage.
|
||||
toggleButton.selectedProperty().addListener((o, oldValue, newValue) -> {
|
||||
try {
|
||||
byteTag.setValue((byte) (newValue ? 1 : 0));
|
||||
saveWorldData();
|
||||
saveLevelDat();
|
||||
} catch (Exception e) {
|
||||
toggleButton.setSelected(oldValue);
|
||||
LOG.warning("Exception happened when saving world info", e);
|
||||
LOG.warning("Exception happened when saving level.dat", e);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -478,11 +457,11 @@ public final class WorldInfoPage extends SpinnerPane implements WorldManagePage.
|
||||
Integer integer = Lang.toIntOrNull(newValue);
|
||||
if (integer != null) {
|
||||
intTag.setValue(integer);
|
||||
saveWorldData();
|
||||
saveLevelDat();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
jfxTextField.setText(oldValue);
|
||||
LOG.warning("Exception happened when saving world data", e);
|
||||
LOG.warning("Exception happened when saving level.dat", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -499,11 +478,11 @@ public final class WorldInfoPage extends SpinnerPane implements WorldManagePage.
|
||||
Float floatValue = Lang.toFloatOrNull(newValue);
|
||||
if (floatValue != null) {
|
||||
floatTag.setValue(floatValue);
|
||||
saveWorldData();
|
||||
saveLevelDat();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
jfxTextField.setText(oldValue);
|
||||
LOG.warning("Exception happened when saving world data", e);
|
||||
LOG.warning("Exception happened when saving level.dat", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -511,27 +490,30 @@ public final class WorldInfoPage extends SpinnerPane implements WorldManagePage.
|
||||
jfxTextField.setValidators(new DoubleValidator(i18n("input.number"), true));
|
||||
}
|
||||
|
||||
private void saveWorldData() {
|
||||
LOG.info("Saving data of world " + world.getWorldName());
|
||||
private void saveLevelDat() {
|
||||
LOG.info("Saving level.dat of world " + world.getWorldName());
|
||||
try {
|
||||
this.world.writeWorldData();
|
||||
this.world.writeLevelDat(levelDat);
|
||||
} catch (IOException e) {
|
||||
LOG.warning("Failed to save world data", e);
|
||||
LOG.warning("Failed to save level.dat of world " + world.getWorldName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
setFailedReason(null);
|
||||
try {
|
||||
this.isReadOnly = worldManagePage.isReadOnly();
|
||||
this.levelData = world.getLevelData();
|
||||
this.playerData = world.getPlayerData();
|
||||
updateControls();
|
||||
} catch (Exception e) {
|
||||
LOG.warning("Failed to refresh world info", e);
|
||||
setFailedReason(i18n("world.info.failed"));
|
||||
}
|
||||
this.isReadOnly = worldManagePage.isReadOnly();
|
||||
this.setLoading(true);
|
||||
Task.supplyAsync(this::loadWorldInfo)
|
||||
.whenComplete(Schedulers.javafx(), ((result, exception) -> {
|
||||
if (exception == null) {
|
||||
this.levelDat = result;
|
||||
updateControls();
|
||||
setLoading(false);
|
||||
} else {
|
||||
LOG.warning("Failed to load level.dat", exception);
|
||||
setFailedReason(i18n("world.info.failed"));
|
||||
}
|
||||
})).start();
|
||||
}
|
||||
|
||||
private record Dimension(String name) {
|
||||
@@ -612,15 +594,6 @@ public final class WorldInfoPage extends SpinnerPane implements WorldManagePage.
|
||||
return (d >= 0 && d < items.size()) ? items.get(d) : null;
|
||||
}
|
||||
|
||||
static Difficulty of(String name) {
|
||||
for (Difficulty d : items) if (d.name().toLowerCase(Locale.ROOT).equals(name)) return d;
|
||||
return null;
|
||||
}
|
||||
|
||||
String getTagStringValue() {
|
||||
return this.name().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return i18n("world.info.difficulty." + name().toLowerCase(Locale.ROOT));
|
||||
@@ -686,7 +659,7 @@ public final class WorldInfoPage extends SpinnerPane implements WorldManagePage.
|
||||
Files.deleteIfExists(output);
|
||||
iconImageView.setImage(FXUtils.newBuiltinImage("/assets/img/unknown_server.png"));
|
||||
} catch (IOException e) {
|
||||
LOG.warning("Failed to delete world icon ", e);
|
||||
LOG.warning("Failed to delete world icon " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import javafx.scene.Node;
|
||||
import javafx.scene.control.ListCell;
|
||||
import javafx.scene.control.Skin;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.input.MouseButton;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
@@ -242,7 +243,7 @@ public final class WorldListPage extends ListPageBase<World> implements VersionP
|
||||
private final WorldListPage page;
|
||||
|
||||
private final RipplerContainer graphic;
|
||||
private final ImageContainer imageView;
|
||||
private final ImageView imageView;
|
||||
private final Tooltip leftTooltip;
|
||||
private final TwoLineListItem content;
|
||||
private final JFXButton btnLaunch;
|
||||
@@ -261,8 +262,9 @@ public final class WorldListPage extends ListPageBase<World> implements VersionP
|
||||
root.setLeft(left);
|
||||
left.setPadding(new Insets(0, 8, 0, 0));
|
||||
|
||||
this.imageView = new ImageContainer(32);
|
||||
this.imageView = new ImageView();
|
||||
left.getChildren().add(imageView);
|
||||
FXUtils.limitSize(imageView, 32, 32);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -276,10 +278,12 @@ public final class WorldListPage extends ListPageBase<World> implements VersionP
|
||||
root.setRight(right);
|
||||
right.setAlignment(Pos.CENTER_RIGHT);
|
||||
|
||||
btnLaunch = FXUtils.newToggleButton4(SVG.ROCKET_LAUNCH);
|
||||
btnLaunch = new JFXButton();
|
||||
btnLaunch.visibleProperty().bind(page.supportQuickPlayProperty());
|
||||
btnLaunch.managedProperty().bind(btnLaunch.visibleProperty());
|
||||
right.getChildren().add(btnLaunch);
|
||||
btnLaunch.getStyleClass().add("toggle-icon4");
|
||||
btnLaunch.setGraphic(SVG.ROCKET_LAUNCH.createIcon());
|
||||
FXUtils.installFastTooltip(btnLaunch, i18n("version.launch"));
|
||||
btnLaunch.setOnAction(event -> {
|
||||
World world = getItem();
|
||||
@@ -287,8 +291,10 @@ public final class WorldListPage extends ListPageBase<World> implements VersionP
|
||||
page.launch(world);
|
||||
});
|
||||
|
||||
JFXButton btnMore = FXUtils.newToggleButton4(SVG.MORE_VERT);
|
||||
JFXButton btnMore = new JFXButton();
|
||||
right.getChildren().add(btnMore);
|
||||
btnMore.getStyleClass().add("toggle-icon4");
|
||||
btnMore.setGraphic(SVG.MORE_VERT.createIcon());
|
||||
btnMore.setOnAction(event -> {
|
||||
World world = getItem();
|
||||
if (world != null)
|
||||
|
||||
@@ -78,9 +78,9 @@ public final class WorldManagePage extends DecoratorAnimatedPage implements Deco
|
||||
updateSessionLockChannel();
|
||||
|
||||
try {
|
||||
this.world.reloadWorldData();
|
||||
this.world.reloadLevelDat();
|
||||
} catch (IOException e) {
|
||||
LOG.warning("Can not load world data of world: " + this.world.getFile(), e);
|
||||
LOG.warning("Can not load world level.dat of world: " + this.world.getFile(), e);
|
||||
this.addEventHandler(Navigator.NavigationEvent.NAVIGATED, event -> closePageForLoadingFail());
|
||||
}
|
||||
|
||||
@@ -106,9 +106,9 @@ public final class WorldManagePage extends DecoratorAnimatedPage implements Deco
|
||||
public void refresh() {
|
||||
updateSessionLockChannel();
|
||||
try {
|
||||
world.reloadWorldData();
|
||||
world.reloadLevelDat();
|
||||
} catch (IOException e) {
|
||||
LOG.warning("Can not load world data of world: " + world.getFile(), e);
|
||||
LOG.warning("Can not load world level.dat of world: " + world.getFile(), e);
|
||||
closePageForLoadingFail();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Hello Minecraft! Launcher
|
||||
* Copyright (C) 2020 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.wizard;
|
||||
|
||||
public enum WizardNavigationResult {
|
||||
PROCEED {
|
||||
@Override
|
||||
public boolean getDeferredComputation() {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
DENY {
|
||||
@Override
|
||||
public boolean getDeferredComputation() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
public abstract boolean getDeferredComputation();
|
||||
}
|
||||
@@ -20,12 +20,20 @@ package org.jackhuang.hmcl.util;
|
||||
import javafx.application.Platform;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Alert.AlertType;
|
||||
import org.jackhuang.hmcl.Metadata;
|
||||
import org.jackhuang.hmcl.countly.CrashReport;
|
||||
import org.jackhuang.hmcl.ui.CrashWindow;
|
||||
import org.jackhuang.hmcl.upgrade.IntegrityChecker;
|
||||
import org.jackhuang.hmcl.upgrade.UpdateChecker;
|
||||
import org.jackhuang.hmcl.util.io.NetworkUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.HashMap;
|
||||
|
||||
import static org.jackhuang.hmcl.util.logging.Logger.LOG;
|
||||
import static org.jackhuang.hmcl.util.Pair.pair;
|
||||
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
||||
import static org.jackhuang.hmcl.util.logging.Logger.LOG;
|
||||
|
||||
/**
|
||||
* @author huangyuhui
|
||||
@@ -95,6 +103,9 @@ public final class CrashReporter implements Thread.UncaughtExceptionHandler {
|
||||
if (showCrashWindow) {
|
||||
new CrashWindow(report).show();
|
||||
}
|
||||
if (!UpdateChecker.isOutdated() && IntegrityChecker.isSelfVerified()) {
|
||||
reportToServer(report);
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (Throwable handlingException) {
|
||||
@@ -104,4 +115,22 @@ public final class CrashReporter implements Thread.UncaughtExceptionHandler {
|
||||
FileSaver.shutdown();
|
||||
LOG.shutdown();
|
||||
}
|
||||
|
||||
private void reportToServer(CrashReport crashReport) {
|
||||
Thread t = new Thread(() -> {
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("crash_report", crashReport.getDisplayText());
|
||||
map.put("version", Metadata.VERSION);
|
||||
map.put("log", LOG.getLogs());
|
||||
try {
|
||||
String response = NetworkUtils.doPost(URI.create(Metadata.PUBLISH_URL + "/hmcl/crash.php"), map);
|
||||
if (StringUtils.isNotBlank(response))
|
||||
LOG.error("Crash server response: " + response);
|
||||
} catch (IOException ex) {
|
||||
LOG.error("Unable to post HMCL server.", ex);
|
||||
}
|
||||
});
|
||||
t.setDaemon(true);
|
||||
t.start();
|
||||
}
|
||||
}
|
||||
@@ -236,11 +236,7 @@ public final class NativePatcher {
|
||||
minVersion = "1.6";
|
||||
} else if (platform.equals(Platform.LINUX_RISCV64)) {
|
||||
minVersion = "1.8";
|
||||
|
||||
if (gameVersion.compareTo("1.21.5") > 0 && gameVersion.compareTo("26.1-snapshot-8") < 0) {
|
||||
// LWJGL version mismatch
|
||||
return SupportStatus.UNSUPPORTED;
|
||||
}
|
||||
maxVersion = "1.21.5";
|
||||
} else if (platform.equals(Platform.LINUX_LOONGARCH64)) {
|
||||
minVersion = "1.6";
|
||||
} else if (platform.equals(Platform.LINUX_LOONGARCH64_OW)) {
|
||||
|
||||
@@ -79,11 +79,10 @@ public final class SelfDependencyPatcher {
|
||||
private final byte[] buffer = new byte[IOUtils.DEFAULT_BUFFER_SIZE];
|
||||
private final MessageDigest digest = DigestUtils.getDigest("SHA-1");
|
||||
|
||||
private SelfDependencyPatcher() throws PatchException {
|
||||
private SelfDependencyPatcher() throws IncompatibleVersionException {
|
||||
// We can only self-patch JavaFX on specific platform.
|
||||
if (dependencies == null) {
|
||||
throw new PatchException("Unsupported platform: operating system %s, architecture %s".formatted(
|
||||
System.getProperty("os.name"), System.getProperty("os.arch")));
|
||||
throw new IncompatibleVersionException();
|
||||
}
|
||||
|
||||
final String customUrl = System.getProperty("hmcl.openjfx.repo");
|
||||
@@ -160,12 +159,18 @@ public final class SelfDependencyPatcher {
|
||||
/**
|
||||
* Patch in any missing dependencies, if any.
|
||||
*/
|
||||
public static void patch() throws PatchException, CancellationException {
|
||||
public static void patch() throws PatchException, IncompatibleVersionException, CancellationException {
|
||||
// Do nothing if JavaFX is detected
|
||||
try {
|
||||
Class.forName("javafx.application.Application");
|
||||
return;
|
||||
} catch (Exception ignored) {
|
||||
try {
|
||||
Class.forName("javafx.application.Application");
|
||||
return;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
} catch (UnsupportedClassVersionError error) {
|
||||
// Loading the JavaFX class was unsupported.
|
||||
// We are probably on 8 and its on 11
|
||||
throw new IncompatibleVersionException();
|
||||
}
|
||||
|
||||
SelfDependencyPatcher patcher = new SelfDependencyPatcher();
|
||||
@@ -373,15 +378,14 @@ public final class SelfDependencyPatcher {
|
||||
}
|
||||
|
||||
public static class PatchException extends Exception {
|
||||
PatchException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
PatchException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
||||
public static class IncompatibleVersionException extends Exception {
|
||||
}
|
||||
|
||||
public static class ProgressFrame extends JDialog {
|
||||
|
||||
private final JProgressBar progressBar;
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
|
||||
.scroll-bar .thumb {
|
||||
-fx-fill: -monet-surface-tint;
|
||||
-fx-arc-width: 8;
|
||||
-fx-arc-height: 8;
|
||||
-fx-arc-width: 0;
|
||||
-fx-arc-height: 0;
|
||||
}
|
||||
|
||||
.title-label {
|
||||
@@ -445,7 +445,6 @@
|
||||
-fx-max-height: 55px;
|
||||
-fx-min-height: 55px;
|
||||
-fx-background-color: -monet-primary-container;
|
||||
-fx-opacity: 1; /* Override the opacity of disabled button */
|
||||
-fx-cursor: hand;
|
||||
}
|
||||
|
||||
@@ -533,7 +532,6 @@
|
||||
}
|
||||
|
||||
.jfx-layout-heading {
|
||||
-fx-font-weight: BOLD;
|
||||
-fx-font-size: 20.0px;
|
||||
-fx-alignment: center-left;
|
||||
-fx-padding: 5.0 0.0 5.0 0.0;
|
||||
@@ -792,39 +790,31 @@
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
.jfx-slider .track,
|
||||
.jfx-slider:vertical .track {
|
||||
-fx-background-color: -monet-secondary-container;
|
||||
-fx-background-radius: 5;
|
||||
-fx-background-insets: 0;
|
||||
-fx-pref-width: 2px;
|
||||
-fx-pref-height: 2px;
|
||||
.svg-slider .thumb {
|
||||
-fx-stroke: -monet-on-surface;
|
||||
-fx-fill: -monet-on-surface;
|
||||
}
|
||||
|
||||
.jfx-slider .thumb,
|
||||
.jfx-slider:focused .thumb {
|
||||
.jfx-slider:disabled {
|
||||
-fx-opacity: 0.4;
|
||||
}
|
||||
|
||||
/*******************************************************
|
||||
* *
|
||||
* For the main demo sliders *
|
||||
* *
|
||||
*******************************************************/
|
||||
|
||||
.jfx-slider {
|
||||
-jfx-indicator-position: right;
|
||||
}
|
||||
|
||||
.jfx-slider .track {
|
||||
-fx-background-color: -monet-on-surface-variant-transparent-38;
|
||||
}
|
||||
|
||||
.jfx-slider .thumb {
|
||||
-fx-background-color: -monet-primary;
|
||||
-fx-background-radius: 20;
|
||||
-fx-background-insets: 0;
|
||||
}
|
||||
|
||||
.jfx-slider .colored-track {
|
||||
-fx-background-color: -monet-primary;
|
||||
-fx-background-radius: 5 0 0 5;
|
||||
-fx-background-insets: 0;
|
||||
}
|
||||
|
||||
.jfx-slider .slider-value {
|
||||
-fx-stroke: -monet-inverse-on-surface;
|
||||
-fx-font-size: 10;
|
||||
}
|
||||
|
||||
.jfx-slider .animated-thumb {
|
||||
-fx-pref-width: 30px;
|
||||
-fx-pref-height: 30px;
|
||||
-fx-background-color: -monet-inverse-surface;
|
||||
-fx-background-radius: 50% 50% 50% 0%;
|
||||
-fx-background-insets: 0;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -913,27 +903,22 @@
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
.jfx-progress-bar > .track {
|
||||
-fx-background-color: -monet-secondary-container;
|
||||
.jfx-progress-bar {
|
||||
-fx-pref-width: 500.0;
|
||||
}
|
||||
|
||||
.jfx-progress-bar > .bar,
|
||||
.jfx-progress-bar:indeterminate > .bar{
|
||||
-fx-background-color: -monet-primary;
|
||||
-fx-padding: 1.5;
|
||||
}
|
||||
|
||||
.jfx-progress-bar > .secondary-bar,
|
||||
.jfx-progress-bar:indeterminate > .secondary-bar {
|
||||
-fx-background-color: -monet-secondary;
|
||||
}
|
||||
|
||||
.jfx-progress-bar > .track,
|
||||
.jfx-progress-bar > .bar {
|
||||
.jfx-progress-bar > .track, .jfx-progress-bar > .bar {
|
||||
-fx-background-radius: 0;
|
||||
-fx-background-insets: 0;
|
||||
}
|
||||
|
||||
.jfx-progress-bar > .track {
|
||||
-fx-background-color: -monet-secondary-container;
|
||||
}
|
||||
|
||||
.jfx-progress-bar > .bar {
|
||||
-fx-background-color: -monet-primary;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* *
|
||||
@@ -1066,13 +1051,6 @@
|
||||
-fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.26), 10, 0.12, -1, 2);
|
||||
}
|
||||
|
||||
.card-no-padding {
|
||||
-fx-background-color: -monet-surface-container-low-transparent-80;
|
||||
-fx-background-radius: 4;
|
||||
|
||||
-fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.26), 10, 0.12, -1, 2);
|
||||
}
|
||||
|
||||
.card-non-transparent {
|
||||
-fx-background-color: -monet-surface-container-low;
|
||||
-fx-background-radius: 4;
|
||||
@@ -1171,7 +1149,7 @@
|
||||
-fx-background-insets: 0px;
|
||||
|
||||
-jfx-toggle-color: -monet-primary;
|
||||
-jfx-toggle-line-color: -monet-secondary-container;
|
||||
-jfx-toggle-line-color: -monet-primary-container;
|
||||
-jfx-untoggle-color: -monet-outline;
|
||||
-jfx-untoggle-line-color: -monet-surface-container-highest;
|
||||
-jfx-size: 10;
|
||||
@@ -1453,19 +1431,21 @@
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
.jfx-spinner .arc {
|
||||
.jfx-spinner > .arc {
|
||||
-fx-stroke-width: 3.0;
|
||||
-fx-fill: transparent;
|
||||
-fx-stroke: -monet-primary-container;
|
||||
}
|
||||
|
||||
.jfx-spinner:determinate .percentage {
|
||||
-fx-fill: -monet-on-surface-variant;
|
||||
.jfx-spinner .arc {
|
||||
-fx-stroke-line-cap: round;
|
||||
}
|
||||
|
||||
.first-spinner {
|
||||
-jfx-radius: 20;
|
||||
}
|
||||
|
||||
.first-spinner .arc {
|
||||
.first-spinner > .arc {
|
||||
-fx-stroke-width: 5.0;
|
||||
}
|
||||
|
||||
@@ -1473,7 +1453,7 @@
|
||||
-jfx-radius: 10;
|
||||
}
|
||||
|
||||
.small-spinner .arc {
|
||||
.small-spinner > .arc {
|
||||
-fx-stroke-width: 3.0;
|
||||
}
|
||||
|
||||
@@ -1481,7 +1461,7 @@
|
||||
-jfx-radius: 10;
|
||||
}
|
||||
|
||||
.small-spinner-pane .jfx-spinner .arc {
|
||||
.small-spinner-pane .jfx-spinner > .arc {
|
||||
-fx-stroke-width: 3.0;
|
||||
}
|
||||
|
||||
@@ -1489,7 +1469,7 @@
|
||||
-jfx-radius: 30;
|
||||
}
|
||||
|
||||
.second-spinner .arc {
|
||||
.second-spinner > .arc {
|
||||
-fx-stroke-width: 5.0;
|
||||
}
|
||||
|
||||
@@ -1497,7 +1477,7 @@
|
||||
-jfx-radius: 40;
|
||||
}
|
||||
|
||||
.third-spinner .arc {
|
||||
.third-spinner > .arc {
|
||||
-fx-stroke-width: 5.0;
|
||||
}
|
||||
|
||||
@@ -1505,7 +1485,7 @@
|
||||
-jfx-radius: 50;
|
||||
}
|
||||
|
||||
.fourth-spinner .arc {
|
||||
.fourth-spinner > .arc {
|
||||
-fx-stroke-width: 5.0;
|
||||
}
|
||||
|
||||
@@ -1513,7 +1493,7 @@
|
||||
-jfx-radius: 60;
|
||||
}
|
||||
|
||||
.fifth-spinner .arc {
|
||||
.fifth-spinner > .arc {
|
||||
-fx-stroke-width: 5.0;
|
||||
}
|
||||
|
||||
@@ -1521,7 +1501,7 @@
|
||||
-jfx-radius: 70;
|
||||
}
|
||||
|
||||
.sixth-spinner .arc {
|
||||
.sixth-spinner > .arc {
|
||||
-fx-stroke-width: 5.0;
|
||||
}
|
||||
|
||||
@@ -1529,7 +1509,7 @@
|
||||
-jfx-radius: 80;
|
||||
}
|
||||
|
||||
.seventh-spinner .arc {
|
||||
.seventh-spinner > .arc {
|
||||
-fx-stroke-width: 5.0;
|
||||
}
|
||||
|
||||
@@ -1942,10 +1922,6 @@
|
||||
-fx-padding: 10 16 10 16;
|
||||
}
|
||||
|
||||
.line-component .subtitle-label {
|
||||
-fx-text-fill: -monet-on-surface-variant;
|
||||
}
|
||||
|
||||
.line-component.no-padding .line-component-container {
|
||||
-fx-padding: 0;
|
||||
}
|
||||
@@ -1975,20 +1951,12 @@
|
||||
-fx-font-size: 13px;
|
||||
}
|
||||
|
||||
.line-select-button .menu-container .title-label {
|
||||
-fx-text-fill: -monet-on-surface;
|
||||
}
|
||||
|
||||
.line-select-button .menu-container .subtitle-label {
|
||||
-fx-text-fill: -monet-on-surface-variant;
|
||||
}
|
||||
|
||||
.line-select-button .menu-container:selected .title-label {
|
||||
-fx-text-fill: -monet-primary;
|
||||
}
|
||||
|
||||
.line-select-button .menu-container:selected .subtitle-label {
|
||||
-fx-text-fill: -monet-primary-container;
|
||||
-fx-text-fill: -monet-primary;
|
||||
}
|
||||
|
||||
.line-toggle-button .jfx-toggle-button {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Hello Minecraft! Launcher
|
||||
# Copyright (C) 2026 huangyuhui <huanghongxun2008@126.com> and contributors
|
||||
# Copyright (C) 2025 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
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
about=About
|
||||
about.copyright=Copyright
|
||||
about.copyright.statement=Copyright © 2013-2026 huangyuhui and contributors.
|
||||
about.copyright.statement=Copyright © 2026 huangyuhui
|
||||
about.author=Author
|
||||
about.author.statement=bilibili @huanghongxun
|
||||
about.claim=EULA
|
||||
@@ -401,6 +401,9 @@ extension.schematic=Schematic File
|
||||
extension.world=World Archive
|
||||
|
||||
fatal.create_hmcl_current_directory_failure=Hello Minecraft! Launcher cannot create the HMCL directory (%s). Please move HMCL to another location and reopen it.
|
||||
fatal.javafx.incompatible=Missing JavaFX environment.\n\
|
||||
Hello Minecraft! Launcher cannot automatically install JavaFX on Java <11.\n\
|
||||
Please update your Java to version 11 or later.
|
||||
fatal.javafx.incomplete=The JavaFX environment is incomplete.\n\
|
||||
Please try replacing your Java or reinstalling OpenJFX.
|
||||
fatal.javafx.missing=Missing JavaFX environment. Please open Hello Minecraft! Launcher with Java, which includes OpenJFX.
|
||||
@@ -439,10 +442,10 @@ You can continue to keep the old version of Java.\
|
||||
HMCL can recognize and manage multiple Java versions and will automatically select the appropriate Java for you based on the game version.
|
||||
fatal.deprecated_java_version.download_link=Download Java %d
|
||||
fatal.samba=If you opened Hello Minecraft! Launcher from a Samba network drive, some features might not be working. Please try updating your Java or moving the launcher to another directory.
|
||||
fatal.illegal_char=Your working directory contains an illegal character "=". You will not be able to use authlib-injector or change the skin of your offline account.
|
||||
fatal.illegal_char=Your user path contains an illegal character "=". You will not be able to use authlib-injector or change the skin of your offline account.
|
||||
fatal.unsupported_platform=Minecraft is not fully supported on your platform yet, so you may experience missing features or even be unable to launch the game.\n\
|
||||
\n\
|
||||
If you cannot launch Minecraft 1.17 and later, you can try switching the "Renderer" to "Mesa LLVMpipe" in "Global/Instance-specific Settings → Advanced Settings" to use CPU rendering for better compatibility.
|
||||
If you cannot launch Minecraft 1.17 and later, you can try switching the "Renderer" to "Mesa LLVMpipe (Software)" in "Global/Instance-specific Settings → Advanced Settings" to use CPU rendering for better compatibility.
|
||||
fatal.unsupported_platform.loongarch=Hello Minecraft! Launcher has provided support for the Loongson platform.\n\
|
||||
If you encounter problems when playing a game, you can visit https://docs.hmcl.net/groups.html for help.
|
||||
fatal.unsupported_platform.macos_arm64=Hello Minecraft! Launcher has provided support for the Apple silicon platform, using native ARM Java to launch games to get a smoother gaming experience.\n\
|
||||
@@ -1365,13 +1368,9 @@ settings.advanced.post_exit_command=Post-exit Command
|
||||
settings.advanced.post_exit_command.prompt=Commands to execute after the game exits
|
||||
settings.advanced.renderer=Renderer
|
||||
settings.advanced.renderer.default=Default
|
||||
settings.advanced.renderer.default.desc=OpenGL
|
||||
settings.advanced.renderer.d3d12=Mesa D3D12
|
||||
settings.advanced.renderer.d3d12.desc=DirectX 12 (Poor performance and compatibility)
|
||||
settings.advanced.renderer.llvmpipe=Mesa LLVMpipe
|
||||
settings.advanced.renderer.llvmpipe.desc=Software (Poor performance, best compatibility)
|
||||
settings.advanced.renderer.llvmpipe=Mesa LLVMpipe (Software)
|
||||
settings.advanced.renderer.zink=Mesa Zink
|
||||
settings.advanced.renderer.zink.desc=Vulkan (Best performance, poor compatibility)
|
||||
settings.advanced.server_ip=Server Address
|
||||
settings.advanced.server_ip.prompt=Automatically join after launching the game
|
||||
settings.advanced.unsupported_system_options=Settings not applicable to the current system
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Hello Minecraft! Launcher
|
||||
# Copyright (C) 2026 huangyuhui <huanghongxun2008@126.com> and contributors
|
||||
# Copyright (C) 2025 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
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
about=Acerca de
|
||||
about.copyright=Copyright
|
||||
about.copyright.statement=Copyright © 2026 huangyuhui.
|
||||
about.author=Autor
|
||||
about.author.statement=bilibili @huanghongxun
|
||||
about.claim=EULA
|
||||
@@ -371,6 +372,9 @@ extension.mod=Archivo mod
|
||||
extension.world=Archivo del mundo
|
||||
|
||||
fatal.create_hmcl_current_directory_failure=El lanzador no puede crear el directorio HMCL (%s). Por favor, mueva el lanzador a otra ubicación y vuelva a abrirlo.
|
||||
fatal.javafx.incompatible=No se encontró un entorno JavaFX.\n\
|
||||
Hello Minecraft! Launcher no puede instalar automáticamente JavaFX con versiones de Java inferiores a la 11.\n\
|
||||
Por favor, actualice su Java a la versión 11 o posterior.
|
||||
fatal.javafx.incomplete=El entorno JavaFX está incompleto.\n\
|
||||
Por favor, intente reemplazar su Java o reinstalar OpenJFX.
|
||||
fatal.javafx.missing=No se encontró un entorno JavaFX.\n\
|
||||
@@ -415,7 +419,7 @@ fatal.illegal_char=Su ruta de usuario contiene un carácter ilegal «=», por lo
|
||||
Por ejemplo, no podrá utilizar authlib-injector o cambiar el skin de su cuenta offline.
|
||||
fatal.unsupported_platform=Minecraft aún no es totalmente compatible con tu plataforma, por lo que es posible que falten funciones o incluso que no puedas iniciar el juego.\n\
|
||||
\n\
|
||||
Si no puedes iniciar Minecraft 1.17 y versiones posteriores, puedes intentar cambiar el «Renderizador» a «Mesa LLVMpipe» en «Configuración global/específica de la instancia → Configuración avanzada» para utilizar el renderizado por CPU y mejorar la compatibilidad.
|
||||
Si no puedes iniciar Minecraft 1.17 y versiones posteriores, puedes intentar cambiar el «Renderizador» a «Mesa LLVMpipe (Software)» en «Configuración global/específica de la instancia → Configuración avanzada» para utilizar el renderizado por CPU y mejorar la compatibilidad.
|
||||
fatal.unsupported_platform.loongarch=Hello Minecraft! Launcher ha prestado apoyo a la plataforma Loongson.\n\
|
||||
Si tienes problemas al jugar, puedes visitar https://docs.hmcl.net/groups.html para obtener ayuda.
|
||||
fatal.unsupported_platform.macos_arm64=Hello Minecraft! Launcher ha proporcionado soporte para la plataforma de chips de Apple, utilizando Java nativo de ARM para ejecutar juegos y conseguir una experiencia de juego más fluida.\n\
|
||||
@@ -1268,14 +1272,10 @@ settings.advanced.process_priority.high=Alta
|
||||
settings.advanced.post_exit_command=Comando post-salida
|
||||
settings.advanced.post_exit_command.prompt=El comando se ejecuta después de que el juego se detenga
|
||||
settings.advanced.renderer=Renderizador
|
||||
settings.advanced.renderer.default=Por defecto
|
||||
settings.advanced.renderer.default.desc=OpenGL
|
||||
settings.advanced.renderer.default=Predeterminado
|
||||
settings.advanced.renderer.d3d12=Mesa D3D12
|
||||
settings.advanced.renderer.d3d12.desc=DirectX 12 (Rendimiento y compatibilidad deficientes)
|
||||
settings.advanced.renderer.llvmpipe=Mesa LLVMpipe
|
||||
settings.advanced.renderer.llvmpipe.desc=Software (Bajo rendimiento, máxima compatibilidad)
|
||||
settings.advanced.renderer.llvmpipe=Mesa LLVMpipe (Software)
|
||||
settings.advanced.renderer.zink=Mesa Zink
|
||||
settings.advanced.renderer.zink.desc=Vulkan (Máximo rendimiento, baja compatibilidad)
|
||||
settings.advanced.server_ip=Dirección del servidor
|
||||
settings.advanced.server_ip.prompt=Entrar automáticamente después de ejecutar el juego
|
||||
settings.advanced.unsupported_system_options=Configuración no aplicable al sistema actual
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Hello Minecraft! Launcher
|
||||
# Copyright (C) 2026 huangyuhui <huanghongxun2008@126.com> and contributors
|
||||
# Copyright (C) 2025 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
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
about=について
|
||||
about.copyright=著作権
|
||||
about.copyright.statement=Copyright © 2026 huangyuhui
|
||||
about.author=著者
|
||||
about.author.statement=bilibili @huanghongxun
|
||||
about.claim=EULA
|
||||
@@ -321,6 +322,7 @@ extension.datapack=Datapack
|
||||
extension.mod=Modファイル
|
||||
extension.world=World zip
|
||||
|
||||
fatal.javafx.incompatible=アプリケーションは11未満の現在のJava環境でJavaFXにパッチを適用できません。\nこのアプリは、JDK11以降またはJavaFXがバンドルされたJDKを使用して実行してください。
|
||||
fatal.javafx.missing=JavaFXがありません。\nJava11以降を使用している場合は、Oracle JRE 8にダウングレードするか、BellSoft Liberica FullJREをインストールしてください。\n他のOpenJDKビルドを使用している場合は、OpenJFXが含まれていることを確認してください。
|
||||
fatal.config_loading_failure=構成にアクセスできません。\nHelloMinecraftを確認してください。Launcherには、「%s」とその中のファイルへの読み取りおよび書き込みアクセス権があります。
|
||||
fatal.migration_requires_manual_reboot=更新が完了しました。Hello Minecraftを再開してください!ランチャー。
|
||||
@@ -329,7 +331,7 @@ fatal.samba=If you are trying to run HMCL in a shared folder by Samba, HMCL may
|
||||
fatal.illegal_char=ユーザーフォルダーのパスに不正な文字'='が含まれています, ログインアカウントやオフラインログインではスキンの変更ができなくなり。
|
||||
fatal.unsupported_platform=現在、お使いのプラットフォームでは Minecraft が完全にはサポートされていないため、機能が欠けたり、ゲームを起動できない場合があります。\n\
|
||||
\n\
|
||||
Minecraft 1.17 以降を起動できない場合は、「グローバル/インスタンス固有の設定 → 詳細設定」で「レンダラー」を「Mesa LLVMpipe」に切り替え、CPU レンダリングを使用することで互換性が向上する可能性があります。
|
||||
Minecraft 1.17 以降を起動できない場合は、「グローバル/インスタンス固有の設定 → 詳細設定」で「レンダラー」を「Mesa LLVMpipe (ソフト)」に切り替え、CPU レンダリングを使用することで互換性が向上する可能性があります。
|
||||
|
||||
file=ファイル
|
||||
|
||||
@@ -792,13 +794,9 @@ settings.advanced.post_exit_command=終了後のコマンド
|
||||
settings.advanced.post_exit_command.prompt=ゲーム終了後に実行されます
|
||||
settings.advanced.renderer=レンダラー
|
||||
settings.advanced.renderer.default=デフォルト
|
||||
settings.advanced.renderer.default.desc=OpenGL
|
||||
settings.advanced.renderer.d3d12=Mesa D3D12
|
||||
settings.advanced.renderer.d3d12.desc=DirectX 12 (低パフォーマンス、低互換性)
|
||||
settings.advanced.renderer.llvmpipe=Mesa LLVMpipe
|
||||
settings.advanced.renderer.llvmpipe.desc=ソフトウェア (低速だが、互換性は最高)
|
||||
settings.advanced.renderer.llvmpipe=Mesa LLVMpipe (ソフト)
|
||||
settings.advanced.renderer.zink=Mesa Zink
|
||||
settings.advanced.renderer.zink.desc=Vulkan (最高パフォーマンス、低互換性)
|
||||
settings.advanced.server_ip=サーバーアドレス
|
||||
settings.advanced.server_ip.prompt=ゲームの起動時にサーバーに参加する
|
||||
settings.advanced.unsupported_system_options=サポートされていないシステムオプション
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Hello Minecraft! Launcher
|
||||
# Copyright (C) 2026 huangyuhui <huanghongxun2008@126.com> and contributors
|
||||
# Copyright (C) 2025 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
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
about=有涉
|
||||
about.copyright=持權
|
||||
about.copyright.statement=© 2026 huangyuhui 持權
|
||||
about.author=作者
|
||||
about.author.statement=嗶站 @huanghongxun
|
||||
about.claim=客契
|
||||
@@ -367,6 +368,7 @@ extension.mod=改囊案
|
||||
extension.world=生界緊囊
|
||||
|
||||
fatal.create_hmcl_current_directory_failure=HMCL 不能立其案夾 (%s),宜稍遷而再啟之。\n君可求助於 https://docs.hmcl.net/help.html。
|
||||
fatal.javafx.incompatible=JavaFX 闕。\n既行於爪哇之次乎爪哇十一者,HMCL 不能自補之也。宜晉爪哇於十一抑後之者。\n君可求助於 https://docs.hmcl.net/help.html。
|
||||
fatal.javafx.incomplete=JavaFX 損。宜更爪哇,抑復置 OpenJFX。
|
||||
fatal.javafx.missing=JavaFX 闕。君須行 HMCL 於爪哇之俻 OpenJFX 者。\n君可求助於 https://docs.hmcl.net/help.html。
|
||||
fatal.config_change_owner_root=君方啟 HMCL 以根戶簿,是則他戶簿或不能啟之。\n君可求助於 https://docs.hmcl.net/help.html。\n猶啟諸?
|
||||
@@ -383,7 +385,7 @@ fatal.deprecated_java_version.update=HMCL 之晉也,將須爪哇十七與新
|
||||
fatal.samba=誠行於案夾之同享以 Samba 者,啟者或不能行。宜新爪哇,抑遷於自案。\n君可求助於 https://docs.hmcl.net/help.html。
|
||||
fatal.illegal_char=君之案夾名有諱文「=」,是以外載之戶簿、離綫戶簿之更外觀者弗行。\n君可求助於 https://docs.hmcl.net/help.html。
|
||||
fatal.unsupported_platform=礦藝未盡適君之算機,是以戲事或損,至於不能啟。\n\
|
||||
礦藝一點一七以晉之不能啟,或於「(全例/例殊) 戲設 → 進階置設 → 勘誤置設」改「繪製之器」以「Mesa LLVMpipe」,或能兼之。\n君可求助於右上之鈕。
|
||||
礦藝一點一七以晉之不能啟,或於「(全例/例殊) 戲設 → 進階置設 → 勘誤置設」改「繪製之器」以「Mesa LLVMpipe (軟體)」,或能兼之。\n君可求助於右上之鈕。
|
||||
fatal.unsupported_platform.loongarch=HMCL 既適龍芯。\n凡有謬,遽求助於右上之鈕。
|
||||
fatal.unsupported_platform.macos_arm64=HMCL 既適蘋矽。宜啟以 ARM 之爪哇,以益君之戲事。\n誠有謬,宜啟以 x86-64 之爪哇,以益其兼。\n凡有謬,遽求助於右上之鈕。
|
||||
fatal.unsupported_platform.windows_arm64=HMCL 既適 ARM 之視窗。誠有謬,宜啟以 x86 之爪哇。\n誠用<b>栝柑</b>,或須置<a href="ms-windows-store://pdp/?productid=9NQPSL29BFFF">開圖庫兼囊</a>,而後可戯。擊鏈以置之於微軟貨舍。\n君可求助於右上之鈕。
|
||||
@@ -1080,13 +1082,9 @@ settings.advanced.post_exit_command=令於戲訖
|
||||
settings.advanced.post_exit_command.prompt=將後戲訖而行
|
||||
settings.advanced.renderer=繪器
|
||||
settings.advanced.renderer.default=本
|
||||
settings.advanced.renderer.default.desc=開圖庫
|
||||
settings.advanced.renderer.d3d12=Mesa D3D12
|
||||
settings.advanced.renderer.d3d12.desc=DirectX 12 (效與所適皆差,勘誤之用)
|
||||
settings.advanced.renderer.llvmpipe=Mesa LLVMpipe
|
||||
settings.advanced.renderer.llvmpipe.desc=軟繪器 (效差,所適至)
|
||||
settings.advanced.renderer.llvmpipe=Mesa LLVMpipe (軟繪器)
|
||||
settings.advanced.renderer.zink=Mesa Zink
|
||||
settings.advanced.renderer.zink.desc=Vulkan (效至,所適差)
|
||||
settings.advanced.server_ip=伺服器之址
|
||||
settings.advanced.server_ip.prompt=本之址,啟訖徑入是伺服器
|
||||
settings.advanced.unsupported_system_options=不逮今之械網所選
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Hello Minecraft! Launcher
|
||||
# Copyright (C) 2026 huangyuhui <huanghongxun2008@126.com> and contributors
|
||||
# Copyright (C) 2025 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
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
about=О лаунчере
|
||||
about.copyright=Авторские права
|
||||
about.copyright.statement=Авторские права © 2026 huangyuhui.
|
||||
about.author=Автор
|
||||
about.author.statement=bilibili @huanghongxun
|
||||
about.claim=EULA
|
||||
@@ -371,6 +372,9 @@ extension.mod=Файл мода
|
||||
extension.world=Архив мира
|
||||
|
||||
fatal.create_hmcl_current_directory_failure=Лаунчер не может создать папку HMCL (%s). Пожалуйста, переместите лаунчер в другое место и откройте его снова.
|
||||
fatal.javafx.incompatible=Отсутствует среда JavaFX.\n\
|
||||
Лаунчер не может автоматически установить JavaFX на Java <11.\n\
|
||||
Обновите Java до версии 11 или более поздней.
|
||||
fatal.javafx.incomplete=Среда JavaFX является неполной.\n\
|
||||
Попробуйте заменить Java или переустановить OpenJFX.
|
||||
fatal.javafx.missing=Отсутствует среда JavaFX.\n\
|
||||
@@ -409,7 +413,7 @@ fatal.illegal_char=Недопустимый символ «=» в пути к п
|
||||
Вы не сможете использовать аккаунт authlib-injector или изменить скин для аккаунта в режиме офлайн.
|
||||
fatal.unsupported_platform=Minecraft еще не полностью поддерживается на вашей платформе, поэтому вы можете столкнуться с отсутствием функций или даже не сможете запустить игру.\n\
|
||||
\n\
|
||||
Если вы не можете запустить Minecraft версии 1.17 и новее, попробуйте переключить «Рендерер» на «Mesa LLVMpipe» в разделе «Глобальные/настройки экземпляра → Расширенные настройки», чтобы использовать рендеринг через CPU для лучшей совместимости.
|
||||
Если вы не можете запустить Minecraft версии 1.17 и новее, попробуйте переключить «Рендерер» на «Mesa LLVMpipe (Программный)» в разделе «Глобальные/настройки экземпляра → Расширенные настройки», чтобы использовать рендеринг через CPU для лучшей совместимости.
|
||||
fatal.unsupported_platform.loongarch=Лаунчер обеспечил поддержку платформы Loongson.\n\
|
||||
Если у вас возникнут проблемы во время игры, вы можете обратиться за помощью на сайт https://docs.hmcl.net/groups.html.
|
||||
fatal.unsupported_platform.macos_arm64=Лаунчер обеспечил поддержку платформы Apple silicon, используя родную ARM Java для запуска игр, чтобы получить более плавный игровой опыт.\n\
|
||||
@@ -1260,13 +1264,9 @@ settings.advanced.post_exit_command=Команда после выхода
|
||||
settings.advanced.post_exit_command.prompt=Команды, которые необходимо выполнить после выхода из игры
|
||||
settings.advanced.renderer=Рендерер
|
||||
settings.advanced.renderer.default=По умолчанию
|
||||
settings.advanced.renderer.default.desc=OpenGL
|
||||
settings.advanced.renderer.d3d12=Mesa D3D12
|
||||
settings.advanced.renderer.d3d12.desc=DirectX 12 (Низкая производительность и совместимость)
|
||||
settings.advanced.renderer.llvmpipe=Mesa LLVMpipe
|
||||
settings.advanced.renderer.llvmpipe.desc=ПО (Низкая производительность, лучшая совместимость)
|
||||
settings.advanced.renderer.llvmpipe=Mesa LLVMpipe (Программный)
|
||||
settings.advanced.renderer.zink=Mesa Zink
|
||||
settings.advanced.renderer.zink.desc=Vulkan (Лучшая производительность, низкая совместимость)
|
||||
settings.advanced.server_ip=Адрес сервера
|
||||
settings.advanced.server_ip.prompt=Присоединяться к серверу при запуске игры
|
||||
settings.advanced.unsupported_system_options=Настройки, не применимые к текущей системе
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Hello Minecraft! Launcher
|
||||
# Copyright (C) 2026 huangyuhui <huanghongxun2008@126.com> and contributors
|
||||
# Copyright (C) 2025 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
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
about=Про програму
|
||||
about.copyright=Авторське право
|
||||
about.copyright.statement=Авторське право © 2026 huangyuhui
|
||||
about.author=Автор
|
||||
about.author.statement=bilibili @huanghongxun
|
||||
about.claim=Ліцензійна угода з кінцевим користувачем (EULA)
|
||||
@@ -369,6 +370,9 @@ extension.mod=Файл мода
|
||||
extension.world=Архів світу
|
||||
|
||||
fatal.create_hmcl_current_directory_failure=Hello Minecraft! Лаунчер не може створити каталог HMCL (%s). Перемістіть HMCL в інше місце та відкрийте його знову.
|
||||
fatal.javafx.incompatible=Відсутнє середовище JavaFX. \n\
|
||||
Hello Minecraft! Лаунчер не може автоматично встановити JavaFX на Java <11. \n\
|
||||
Оновіть вашу Java до версії 11 або новішої.
|
||||
fatal.javafx.incomplete=Середовище JavaFX неповне. \n\
|
||||
Спробуйте замінити вашу Java або перевстановити OpenJFX.
|
||||
fatal.javafx.missing=Відсутнє середовище JavaFX. Відкрийте Hello Minecraft! Лаунчер за допомогою Java, яка включає OpenJFX.
|
||||
@@ -395,7 +399,7 @@ fatal.samba=Якщо ви відкрили Hello Minecraft! Лаунчер з м
|
||||
fatal.illegal_char=Ваш шлях користувача містить недопустимий символ "=". Ви не зможете використовувати authlib-injector або змінювати скін вашого автономного облікового запису.
|
||||
fatal.unsupported_platform=Minecraft ще не повністю підтримується на вашій платформі, тому можливі відсутні функції або навіть неможливість запуску гри.\n\
|
||||
\n\
|
||||
Якщо ви не можете запустити Minecraft версії 1.17 і новіші, спробуйте змінити «Рендерер» на «Mesa LLVMpipe» у розділі «Глобальні/налаштування екземпляра → Розширені налаштування», щоб використовувати рендеринг через CPU для кращої сумісності.
|
||||
Якщо ви не можете запустити Minecraft версії 1.17 і новіші, спробуйте змінити «Рендерер» на «Mesa LLVMpipe (Програмний)» у розділі «Глобальні/налаштування екземпляра → Розширені налаштування», щоб використовувати рендеринг через CPU для кращої сумісності.
|
||||
fatal.unsupported_platform.loongarch=Hello Minecraft! Лаунчер надав підтримку платформи Loongson.\n\
|
||||
Якщо у вас виникли проблеми під час гри, ви можете відвідати https://docs.hmcl.net/groups.html для отримання допомоги.
|
||||
fatal.unsupported_platform.macos_arm64=Hello Minecraft! Лаунчер надав підтримку платформи Apple silicon, використовуючи нативну ARM Java для запуску ігор для отримання плавнішого ігрового досвіду.\n\
|
||||
@@ -1207,13 +1211,9 @@ settings.advanced.post_exit_command=Команда після виходу
|
||||
settings.advanced.post_exit_command.prompt=Команди для виконання після виходу з гри
|
||||
settings.advanced.renderer=Рендерер
|
||||
settings.advanced.renderer.default=По умолчанию
|
||||
settings.advanced.renderer.default.desc=OpenGL
|
||||
settings.advanced.renderer.d3d12=Mesa D3D12
|
||||
settings.advanced.renderer.d3d12.desc=DirectX 12 (Погана продуктивність та сумісність)
|
||||
settings.advanced.renderer.llvmpipe=Mesa LLVMpipe
|
||||
settings.advanced.renderer.llvmpipe.desc=Програмний (Погана продуктивність, найкраща сумісність)
|
||||
settings.advanced.renderer.llvmpipe=Mesa LLVMpipe (Програмний)
|
||||
settings.advanced.renderer.zink=Mesa Zink
|
||||
settings.advanced.renderer.zink.desc=Vulkan (Найкраща продуктивність, погана сумісність)
|
||||
settings.advanced.server_ip=Адреса сервера
|
||||
settings.advanced.server_ip.prompt=Автоматично приєднатися після запуску гри
|
||||
settings.advanced.unsupported_system_options=Налаштування, що не застосовуються до поточної системи
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Hello Minecraft! Launcher
|
||||
# Copyright (C) 2026 huangyuhui <huanghongxun2008@126.com> and contributors
|
||||
# Copyright (C) 2025 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
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
about=關於
|
||||
about.copyright=著作權
|
||||
about.copyright.statement=著作權所有 © 2013-2026 huangyuhui 與貢獻者
|
||||
about.copyright.statement=著作權所有 © 2026 huangyuhui
|
||||
about.author=作者
|
||||
about.author.statement=bilibili @huanghongxun
|
||||
about.claim=使用者協議
|
||||
@@ -30,7 +30,7 @@ about.legal=法律宣告
|
||||
about.thanks_to=鳴謝
|
||||
about.thanks_to.bangbang93.statement=提供 BMCLAPI 下載來源。請贊助支援 BMCLAPI!
|
||||
about.thanks_to.burningtnt.statement=為 HMCL 貢獻許多技術支援
|
||||
about.thanks_to.contributors=所有透過 Issue、Pull Request 等管道參與本專案的貢獻者
|
||||
about.thanks_to.contributors=所有透過 Issue、Pull Request 等管道參與本項目的貢獻者
|
||||
about.thanks_to.contributors.statement=沒有開源社群的支援,HMCL 無法走到今天
|
||||
about.thanks_to.gamerteam.statement=提供預設背景圖
|
||||
about.thanks_to.glavo.statement=負責 HMCL 的日常維護
|
||||
@@ -104,7 +104,7 @@ account.methods=登入方式
|
||||
account.methods.authlib_injector=外部登入
|
||||
account.methods.microsoft=Microsoft 帳戶
|
||||
account.methods.microsoft.birth=如何變更帳戶出生日期
|
||||
account.methods.microsoft.code=程式碼 (已自動複製)
|
||||
account.methods.microsoft.code=代碼 (已自動複製)
|
||||
account.methods.microsoft.close_page=已完成 Microsoft 帳戶授權。啟動器將自動執行後續步驟。你現在可以關閉本頁面了。
|
||||
account.methods.microsoft.deauthorize=移除應用存取權
|
||||
account.methods.microsoft.error.add_family=請點擊 <a href="https://support.microsoft.com/account-billing/837badbc-999e-54d2-2617-d19206b9540a">此處</a> 更改你的帳戶出生日期,使年齡滿 18 歲以上,或將帳戶加入到家庭中。
|
||||
@@ -393,6 +393,7 @@ extension.schematic=原理圖檔案
|
||||
extension.world=世界壓縮檔
|
||||
|
||||
fatal.create_hmcl_current_directory_failure=Hello Minecraft! Launcher 無法建立 HMCL 資料夾 (%s),請將 HMCL 移動至其他位置再開啟。
|
||||
fatal.javafx.incompatible=缺少 JavaFX 執行環境。\nHMCL 無法在低於 Java 11 的 Java 環境上自行補全 JavaFX 執行環境。請更新到 Java 11 或更高版本。
|
||||
fatal.javafx.incomplete=JavaFX 執行環境不完整。請嘗試更換你的 Java 或者重新安裝 OpenJFX。
|
||||
fatal.javafx.missing=缺少 JavaFX 執行環境。請使用包含 OpenJFX 的 Java 執行環境開啟 Hello Minecraft! Launcher。
|
||||
fatal.config_change_owner_root=你正在使用 root 帳戶開啟 Hello Minecraft! Launcher,這可能導致你未來無法使用其他帳戶正常開啟 HMCL。\n是否繼續開啟?
|
||||
@@ -408,9 +409,9 @@ fatal.deprecated_java_version=HMCL 未來需要 Java 17 或更高版本才能執
|
||||
fatal.deprecated_java_version.update=更高版本的 HMCL 需要 Java 17 或更高版本才能執行,請安裝最新版本的 Java 以確保 HMCL 能夠完成升級。\n你可以繼續保留舊版本 Java。HMCL 能夠識別與管理多個 Java,並會自動根據遊戲版本為你選取合適的 Java。
|
||||
fatal.deprecated_java_version.download_link=下載 Java %d
|
||||
fatal.samba=如果您正在透過 Samba 共亯的目錄中開啟 Hello Minecraft! Launcher,啟動器可能無法正常工作,請嘗試更新您的 Java 或在本機目錄內開啟 HMCL。
|
||||
fatal.illegal_char=由於您的執行路徑中存在無效字元『=』,您將無法使用外部登入帳戶以及離線登入更換外觀功能。
|
||||
fatal.illegal_char=由於您的使用者目錄路徑中存在無效字元『=』,您將無法使用外部登入帳戶以及離線登入更換外觀功能。
|
||||
fatal.unsupported_platform=Minecraft 尚未對您的平臺提供完善支援,所以可能影響遊戲體驗或無法啟動遊戲。\n\
|
||||
若無法啟動 Minecraft 1.17 及更高版本,可以嘗試在「(全域/實例特定) 遊戲設定 → 進階設定 → 除錯選項」中將「繪製器」切換為「Mesa LLVMpipe」,以獲得更好的相容性。
|
||||
若無法啟動 Minecraft 1.17 及更高版本,可以嘗試在「(全域/實例特定) 遊戲設定 → 進階設定 → 除錯選項」中將「繪製器」切換為「Mesa LLVMpipe (軟體繪製器)」,以獲得更好的相容性。
|
||||
fatal.unsupported_platform.loongarch=Hello Minecraft! Launcher 已為龍芯提供支援。\n如果遇到問題,你可以點擊右上角幫助按鈕進行求助。
|
||||
fatal.unsupported_platform.macos_arm64=Hello Minecraft! Launcher 已為 Apple Silicon 平臺提供支援。使用 ARM 原生 Java 啟動遊戲以獲得更流暢的遊戲體驗。\n如果你在遊戲中遭遇問題,使用 x86-64 架構的 Java 啟動遊戲可能有更好的相容性。
|
||||
fatal.unsupported_platform.windows_arm64=Hello Minecraft! Launcher 已為 Windows on Arm 平臺提供原生支援。如果你在遊戲中遭遇問題,請嘗試使用 x86 架構的 Java 啟動遊戲。\n\n如果你正在使用<b>高通</b>平臺,你可能需要安裝 <a href="ms-windows-store://pdp/?productid=9NQPSL29BFFF">OpenGL 相容包</a>後才能進行遊戲。點擊連結前往 Microsoft Store 安裝相容包。
|
||||
@@ -479,7 +480,7 @@ game.crash.reason.mod_resolution_mod_version.any=%1$s (任意版本)
|
||||
game.crash.reason.forge_repeat_installation=目前遊戲由於 Forge 重複安裝,無法繼續執行。<a href="https://github.com/HMCL-dev/HMCL/issues/1880">此為已知問題</a>\n建議將日誌上傳並回報至 GitHub,以便我們找到更多線索並修復此問題。\n目前你可以在「實例管理 → 自動安裝」中移除 Forge 並重新安裝。
|
||||
game.crash.reason.optifine_repeat_installation=目前遊戲由於重複安裝 OptiFine,無法繼續執行。\n請刪除模組目錄下的 OptiFine 或前往「實例管理 → 自動安裝」移除安裝的 OptiFine。
|
||||
game.crash.reason.optifine_is_not_compatible_with_forge=目前遊戲由於 OptiFine 與目前版本的 Forge 不相容,導致了遊戲崩潰。\n請前往 <a href="https://optifine.net/downloads">OptiFine 官網</a>查看 OptiFine 所相容的 Forge 版本,並嚴格按照對應版本重新安裝遊戲,或在「實例管理 → 自動安裝」中更換版本。\n經測試,Forge 版本過高或過低都可能導致崩潰。
|
||||
game.crash.reason.night_config_fixes=目前遊戲由於 Night Config 庫的一些問題,無法繼續執行。\n你可以嘗試安裝 <a href="https://www.curseforge.com/minecraft/mc-mods/night-config-fixes">Night Config Fixes</a> 模組,這或許能幫助你解決這個問題。\n了解更多,可訪問該模組的 <a href="https://github.com/Fuzss/nightconfigfixes">GitHub 儲存庫</a>。
|
||||
game.crash.reason.night_config_fixes=目前遊戲由於 Night Config 庫的一些問題,無法繼續執行。\n你可以嘗試安裝 <a href="https://www.curseforge.com/minecraft/mc-mods/night-config-fixes">Night Config Fixes</a> 模組,這或許能幫助你解決這個問題。\n了解更多,可訪問該模組的 <a href="https://github.com/Fuzss/nightconfigfixes">GitHub 倉庫</a>。
|
||||
game.crash.reason.mod_files_are_decompressed=目前遊戲由於模組檔案被解壓了,無法繼續執行。\n請直接把整個模組檔案放進模組目錄中即可。\n解壓模組檔案會導致遊戲出錯。請刪除模組目錄中已被解壓的模組,然後再啟動遊戲。
|
||||
game.crash.reason.too_many_mods_lead_to_exceeding_the_id_limit=目前遊戲由於你所安裝的模組過多,超出了遊戲的 ID 限制,無法繼續執行。\n請嘗試安裝<a href="https://www.curseforge.com/minecraft/mc-mods/jeid">JEID</a>等修正模組,或刪除部分大型模組。
|
||||
game.crash.reason.optifine_causes_the_world_to_fail_to_load=目前遊戲可能由於 OptiFine 而無法繼續執行。\n該問題只在特定 OptiFine 版本中出現,你可以嘗試在「實例管理 → 自動安裝」中更換 OptiFine 的版本。
|
||||
@@ -691,7 +692,6 @@ message.info=提示
|
||||
message.success=完成
|
||||
message.unknown=未知
|
||||
message.warning=警告
|
||||
message.question=確認
|
||||
|
||||
modpack=模組包
|
||||
modpack.choose=選取要安裝的遊戲模組包檔案
|
||||
@@ -863,7 +863,7 @@ mods.add.failed=新增模組「%s」失敗。
|
||||
mods.add.success=成功新增模組「%s」。
|
||||
mods.add.title=選取要新增的模組檔案
|
||||
mods.broken_dependency.title=損壞的相依模組
|
||||
mods.broken_dependency.desc=該相依模組曾經存在於模組儲存庫中,但現在已被刪除,請嘗試其他下載源。
|
||||
mods.broken_dependency.desc=該相依模組曾經存在於模組倉庫中,但現在已被刪除,請嘗試其他下載源。
|
||||
mods.category=類別
|
||||
mods.channel.alpha=Alpha
|
||||
mods.channel.beta=Beta
|
||||
@@ -885,7 +885,7 @@ mods.dependency.required=必需相依模組 (必須單獨下載,缺少可能
|
||||
mods.dependency.tool=相依庫 (必須單獨下載,缺少可能會導致遊戲無法啟動)
|
||||
mods.dependency.include=內建相依模組 (作者已經打包在模組檔中,無需單獨下載)
|
||||
mods.dependency.incompatible=不相容模組 (同時安裝此模組和正在下載的模組會導致遊戲無法啟動)
|
||||
mods.dependency.broken=損壞的相依模組 (該模組曾經存在於模組儲存庫中,但現在已被刪除,請嘗試其他下載源)
|
||||
mods.dependency.broken=損壞的相依模組 (該模組曾經存在於模組倉庫中,但現在已被刪除,請嘗試其他下載源)
|
||||
mods.disable=停用
|
||||
mods.download=模組下載
|
||||
mods.download.title=模組下載 - %1s
|
||||
@@ -1031,9 +1031,9 @@ profile.title=遊戲目錄
|
||||
profile.selected=已選取
|
||||
profile.use_relative_path=如可行,則對於遊戲目錄使用相對路徑
|
||||
|
||||
repositories.custom=自訂 Maven 儲存庫 (%s)
|
||||
repositories.custom=自訂 Maven 倉庫 (%s)
|
||||
repositories.maven_central=全球 (Maven Central)
|
||||
repositories.tencentcloud_mirror=中國大陸 (騰訊雲 Maven 儲存庫)
|
||||
repositories.tencentcloud_mirror=中國大陸 (騰訊雲 Maven 倉庫)
|
||||
repositories.chooser=缺少 JavaFX 執行環境。HMCL 需要 JavaFX 才能正常執行。\n點擊「確認」從指定下載源下載 JavaFX 執行時元件並開啟 HMCL。點擊「取消」退出程式。\n選取下載源:
|
||||
repositories.chooser.title=選取 JavaFX 下載源
|
||||
|
||||
@@ -1152,13 +1152,9 @@ settings.advanced.post_exit_command=遊戲結束後執行指令
|
||||
settings.advanced.post_exit_command.prompt=將在遊戲結束後呼叫使用
|
||||
settings.advanced.renderer=繪製器
|
||||
settings.advanced.renderer.default=預設
|
||||
settings.advanced.renderer.default.desc=OpenGL
|
||||
settings.advanced.renderer.d3d12=Mesa D3D12
|
||||
settings.advanced.renderer.d3d12.desc=DirectX 12 (效能與相容性較差,用於除錯)
|
||||
settings.advanced.renderer.llvmpipe=Mesa LLVMpipe
|
||||
settings.advanced.renderer.llvmpipe.desc=軟繪製器 (效能較差,相容性最好)
|
||||
settings.advanced.renderer.llvmpipe=Mesa LLVMpipe (軟繪製器)
|
||||
settings.advanced.renderer.zink=Mesa Zink
|
||||
settings.advanced.renderer.zink.desc=Vulkan (效能最好,相容性較差)
|
||||
settings.advanced.server_ip=伺服器位址
|
||||
settings.advanced.server_ip.prompt=預設,啟動遊戲後直接進入對應伺服器
|
||||
settings.advanced.unsupported_system_options=不適用於目前系統的選項
|
||||
@@ -1281,7 +1277,7 @@ terracotta.difficulty.easiest=目前網路狀況極佳:稍等一下就成功
|
||||
terracotta.difficulty.simple=目前網路狀況較好:建立連線需要一段時間…
|
||||
terracotta.difficulty.medium=目前網路狀態中等:已啟用抗干擾備用線路,連線可能失敗
|
||||
terracotta.difficulty.tough=目前網路狀態極差:已啟用抗干擾備用線路,連線可能失敗
|
||||
terracotta.difficulty.estimate_only=連線成功率由房主和房客的 NAT 類型推算得到,僅供參考。
|
||||
terracotta.difficulty.estimate_only=連接成功率由房主和房客的 NAT 類型推算得到,僅供參考。
|
||||
terracotta.from_local.title=線上核心第三方下載管道
|
||||
terracotta.from_local.desc=在部分地區,內建的預設下載管道可能不穩定或連線緩慢
|
||||
terracotta.from_local.guide=您應下載名為 %s 的線上核心套件。下載完成後,請將檔案拖曳到目前介面來安裝。
|
||||
@@ -1340,7 +1336,7 @@ terracotta.status.fatal.network=未能下載線上核心。請檢查網路連接
|
||||
terracotta.status.fatal.install=嚴重錯誤:無法安裝線上核心
|
||||
terracotta.status.fatal.terracotta=嚴重錯誤:無法與線上核心通訊
|
||||
terracotta.status.fatal.unknown=嚴重錯誤:原因未知
|
||||
terracotta.player_list=玩家清單
|
||||
terracotta.player_list=玩家列表
|
||||
terracotta.player_anonymous=匿名玩家
|
||||
terracotta.player_kind.host=房主
|
||||
terracotta.player_kind.local=你
|
||||
@@ -1349,7 +1345,7 @@ terracotta.unsupported=多人聯機功能尚未支援目前平台。
|
||||
terracotta.unsupported.os.windows.old=多人聯機功能需要 Windows 10 或更高版本。請更新系統。
|
||||
terracotta.unsupported.arch.32bit=多人聯機功能不支援 32 位元系統。請更新至 64 位元系統。
|
||||
terracotta.unsupported.arch.loongarch64_ow=多人聯機功能不支援 Linux LoongArch64 舊世界發行版,請更新至新世界發行版 (如 AOSC OC)。
|
||||
terracotta.unsupported.region=多人聯機功能目前僅為中國內地使用者提供服務,在您所在地區可能不可用。
|
||||
terracotta.unsupported.region=多人聯機功能目前僅為中國內地用戶提供服務,在您所在地區可能不可用。
|
||||
|
||||
unofficial.hint=你正在使用第三方提供的 HMCL。我們無法保證其安全性,請注意甄別。
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Hello Minecraft! Launcher
|
||||
# Copyright (C) 2026 huangyuhui <huanghongxun2008@126.com> and contributors
|
||||
# Copyright (C) 2025 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
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
about=关于
|
||||
about.copyright=版权
|
||||
about.copyright.statement=版权所有 © 2013-2026 huangyuhui 及贡献者
|
||||
about.copyright.statement=版权所有 © 2026 huangyuhui
|
||||
about.author=作者
|
||||
about.author.statement=bilibili @huanghongxun
|
||||
about.claim=用户协议
|
||||
@@ -396,6 +396,7 @@ extension.schematic=原理图文件
|
||||
extension.world=世界压缩包
|
||||
|
||||
fatal.create_hmcl_current_directory_failure=Hello Minecraft! Launcher 无法创建 HMCL 文件夹 (%s),请将 HMCL 移动至其他位置再启动。\n如遇到问题,你可以访问 https://docs.hmcl.net/help.html 页面寻求帮助。
|
||||
fatal.javafx.incompatible=缺少 JavaFX 运行环境。\nHello Minecraft! Launcher 无法在低于 Java 11 的 Java 环境上自行补全 JavaFX 运行环境。请更新到 Java 11 或更高版本。\n你可以访问 https://docs.hmcl.net/help.html 页面寻求帮助。
|
||||
fatal.javafx.incomplete=JavaFX 运行环境不完整。请尝试更换你的 Java 或者重新安装 OpenJFX。
|
||||
fatal.javafx.missing=缺少 JavaFX 运行环境。请使用包含 OpenJFX 的 Java 运行环境启动 Hello Minecraft! Launcher。\n你可以访问 https://docs.hmcl.net/help.html 页面寻求帮助。
|
||||
fatal.config_change_owner_root=你正在使用 root 账户启动 Hello Minecraft! Launcher,这可能导致你未来无法正常使用其他账户正常启动 HMCL。\n你可以访问 https://docs.hmcl.net/help.html 页面寻求帮助。\n是否继续启动?
|
||||
@@ -411,9 +412,9 @@ fatal.deprecated_java_version=HMCL 未来需要 Java 17 或更高版本才能运
|
||||
fatal.deprecated_java_version.update=更高版本的 HMCL 需要 Java 17 或更高版本才能运行,请安装最新版本的 Java 以确保 HMCL 能够完成升级。\n你可以继续保留旧版本 Java。HMCL 能够识别与管理多个 Java,并会自动根据游戏版本为你选择合适的 Java。
|
||||
fatal.deprecated_java_version.download_link=下载 Java %d
|
||||
fatal.samba=如果你正在通过 Samba 共享的文件夹中运行 Hello Minecraft! Launcher,启动器可能无法正常工作。请尝试更新你的 Java 或在本地文件夹内运行 HMCL。\n你可以访问 https://docs.hmcl.net/help.html 页面寻求帮助。
|
||||
fatal.illegal_char=由于你的运行路径中存在非法字符“=”,你将无法使用外置登录账户以及离线登录更换皮肤功能。\n你可以访问 https://docs.hmcl.net/help.html 页面寻求帮助。
|
||||
fatal.illegal_char=由于你的用户文件夹路径中存在非法字符“=”,你将无法使用外置登录账户以及离线登录更换皮肤功能。\n你可以访问 https://docs.hmcl.net/help.html 页面寻求帮助。
|
||||
fatal.unsupported_platform=Minecraft 尚未对你的平台提供完善支持,所以可能影响游戏体验或无法启动游戏。\n\
|
||||
若无法启动 Minecraft 1.17 及更高版本,可以尝试在“(全局/实例特定) 游戏设置 → 高级设置 → 调试选项”中将“渲染器”切换为“Mesa LLVMpipe”,以获得更好的兼容性。\n\
|
||||
若无法启动 Minecraft 1.17 及更高版本,可以尝试在“(全局/实例特定) 游戏设置 → 高级设置 → 调试选项”中将“渲染器”切换为“Mesa LLVMpipe (软渲染器)”,以获得更好的兼容性。\n\
|
||||
如遇到问题,你可以点击右上角帮助按钮进行求助。
|
||||
fatal.unsupported_platform.loongarch=Hello Minecraft! Launcher 已为龙芯提供支持。\n如果遇到问题,你可以点击右上角帮助按钮进行求助。
|
||||
fatal.unsupported_platform.macos_arm64=Hello Minecraft! Launcher 已为 Apple Silicon 平台提供支持。使用 ARM 原生 Java 启动游戏以获得更流畅的游戏体验。\n如果你在游戏中遇到问题,使用 x86-64 架构的 Java 启动游戏可能有更好的兼容性。\n如遇到问题,你可以点击右上角帮助按钮进行求助。
|
||||
@@ -696,7 +697,6 @@ message.info=提示
|
||||
message.success=完成
|
||||
message.unknown=未知
|
||||
message.warning=警告
|
||||
message.question=确认
|
||||
|
||||
modpack=整合包
|
||||
modpack.choose=选择要安装的游戏整合包文件
|
||||
@@ -1157,13 +1157,9 @@ settings.advanced.post_exit_command=游戏结束后执行命令
|
||||
settings.advanced.post_exit_command.prompt=将在游戏结束后调用
|
||||
settings.advanced.renderer=渲染器
|
||||
settings.advanced.renderer.default=默认
|
||||
settings.advanced.renderer.default.desc=OpenGL
|
||||
settings.advanced.renderer.d3d12=Mesa D3D12
|
||||
settings.advanced.renderer.d3d12.desc=DirectX 12 (性能与兼容性较差,用于调试)
|
||||
settings.advanced.renderer.llvmpipe=Mesa LLVMpipe
|
||||
settings.advanced.renderer.llvmpipe.desc=软渲染器 (性能较差,兼容性最好)
|
||||
settings.advanced.renderer.llvmpipe=Mesa LLVMpipe (软渲染器)
|
||||
settings.advanced.renderer.zink=Mesa Zink
|
||||
settings.advanced.renderer.zink.desc=Vulkan (性能最好,兼容性较差)
|
||||
settings.advanced.server_ip=服务器地址
|
||||
settings.advanced.server_ip.prompt=默认,启动游戏后可以直接进入对应服务器
|
||||
settings.advanced.unsupported_system_options=不适用于当前系统的选项
|
||||
|
||||
@@ -781,182 +781,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl:3.4.1": {
|
||||
"name": "org.lwjgl:lwjgl:3.4.1",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl/3.4.1/lwjgl-3.4.1.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl/3.4.1/lwjgl-3.4.1.jar",
|
||||
"sha1": "6105690714874b995aa7812e4f7732a21109276c",
|
||||
"size": 1157957
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl:3.4.1:natives-linux": {
|
||||
"name": "org.lwjgl:lwjgl:3.4.1:natives-linux-arm64",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl/3.4.1/lwjgl-3.4.1-natives-linux-arm64.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl/3.4.1/lwjgl-3.4.1-natives-linux-arm64.jar",
|
||||
"sha1": "46883f3b622d8b4d7f27b627ca3360cda3db0e0e",
|
||||
"size": 120615
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-jemalloc:3.4.1": {
|
||||
"name": "org.lwjgl:lwjgl-jemalloc:3.4.1",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-jemalloc/3.4.1/lwjgl-jemalloc-3.4.1.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-jemalloc/3.4.1/lwjgl-jemalloc-3.4.1.jar",
|
||||
"sha1": "16b663092854fc6adfe0a941e61cae2bb2e437b6",
|
||||
"size": 47872
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-jemalloc:3.4.1:natives-linux": {
|
||||
"name": "org.lwjgl:lwjgl-jemalloc:3.4.1:natives-linux-arm64",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-jemalloc/3.4.1/lwjgl-jemalloc-3.4.1-natives-linux-arm64.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-jemalloc/3.4.1/lwjgl-jemalloc-3.4.1-natives-linux-arm64.jar",
|
||||
"sha1": "7891964dfb723209c6d02b0401432348fb707cc0",
|
||||
"size": 238730
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-openal:3.4.1": {
|
||||
"name": "org.lwjgl:lwjgl-openal:3.4.1",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-openal/3.4.1/lwjgl-openal-3.4.1.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-openal/3.4.1/lwjgl-openal-3.4.1.jar",
|
||||
"sha1": "8508bd60589de0539aa465b78fcf838efd07ae9a",
|
||||
"size": 153919
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-openal:3.4.1:natives-linux": {
|
||||
"name": "org.lwjgl:lwjgl-openal:3.4.1:natives-linux-arm64",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-openal/3.4.1/lwjgl-openal-3.4.1-natives-linux-arm64.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-openal/3.4.1/lwjgl-openal-3.4.1-natives-linux-arm64.jar",
|
||||
"sha1": "3729b70cdd42df5571b075e051fa2fc8586dc538",
|
||||
"size": 839895
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-opengl:3.4.1": {
|
||||
"name": "org.lwjgl:lwjgl-opengl:3.4.1",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-opengl/3.4.1/lwjgl-opengl-3.4.1.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-opengl/3.4.1/lwjgl-opengl-3.4.1.jar",
|
||||
"sha1": "830412cab823c029cda6b9729f9d2ed36cf79959",
|
||||
"size": 937660
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-opengl:3.4.1:natives-linux": {
|
||||
"name": "org.lwjgl:lwjgl-opengl:3.4.1:natives-linux-arm64",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-opengl/3.4.1/lwjgl-opengl-3.4.1-natives-linux-arm64.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-opengl/3.4.1/lwjgl-opengl-3.4.1-natives-linux-arm64.jar",
|
||||
"sha1": "61a4103e56bbaeb74ad3f19ec14299fd6891c4b0",
|
||||
"size": 79752
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-glfw:3.4.1": {
|
||||
"name": "org.lwjgl:lwjgl-glfw:3.4.1",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-glfw/3.4.1/lwjgl-glfw-3.4.1.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-glfw/3.4.1/lwjgl-glfw-3.4.1.jar",
|
||||
"sha1": "a782b1ddd175c9107bf300fd92920579ea65e2a4",
|
||||
"size": 151893
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-glfw:3.4.1:natives-linux": {
|
||||
"name": "org.lwjgl:lwjgl-glfw:3.4.1:natives-linux-arm64",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-glfw/3.4.1/lwjgl-glfw-3.4.1-natives-linux-arm64.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-glfw/3.4.1/lwjgl-glfw-3.4.1-natives-linux-arm64.jar",
|
||||
"sha1": "e5e87034c47118960746077dba46280e8de864b3",
|
||||
"size": 141530
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-stb:3.4.1": {
|
||||
"name": "org.lwjgl:lwjgl-stb:3.4.1",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-stb/3.4.1/lwjgl-stb-3.4.1.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-stb/3.4.1/lwjgl-stb-3.4.1.jar",
|
||||
"sha1": "f077c3dafc31924fbe8acb0b913f08977ba27f8e",
|
||||
"size": 142927
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-stb:3.4.1:natives-linux": {
|
||||
"name": "org.lwjgl:lwjgl-stb:3.4.1:natives-linux-arm64",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-stb/3.4.1/lwjgl-stb-3.4.1-natives-linux-arm64.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-stb/3.4.1/lwjgl-stb-3.4.1-natives-linux-arm64.jar",
|
||||
"sha1": "3bc107f901f931fea07cb0d80b1d74a34b806a2b",
|
||||
"size": 259116
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-tinyfd:3.4.1": {
|
||||
"name": "org.lwjgl:lwjgl-tinyfd:3.4.1",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-tinyfd/3.4.1/lwjgl-tinyfd-3.4.1.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-tinyfd/3.4.1/lwjgl-tinyfd-3.4.1.jar",
|
||||
"sha1": "562697d40dbd2ed0424bf24dcf65d51170f81adf",
|
||||
"size": 15931
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-tinyfd:3.4.1:natives-linux": {
|
||||
"name": "org.lwjgl:lwjgl-tinyfd:3.4.1:natives-linux-arm64",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-tinyfd/3.4.1/lwjgl-tinyfd-3.4.1-natives-linux-arm64.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-tinyfd/3.4.1/lwjgl-tinyfd-3.4.1-natives-linux-arm64.jar",
|
||||
"sha1": "20771d2b4e01f5295156912ab62e170508aef618",
|
||||
"size": 45433
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-freetype:3.4.1": {
|
||||
"name": "org.lwjgl:lwjgl-freetype:3.4.1",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-freetype/3.4.1/lwjgl-freetype-3.4.1.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-freetype/3.4.1/lwjgl-freetype-3.4.1.jar",
|
||||
"sha1": "caa75a37e857efc9b0686e434d708d6420c5b6ea",
|
||||
"size": 464342
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-freetype:3.4.1:natives-linux": {
|
||||
"name": "org.lwjgl:lwjgl-freetype:3.4.1:natives-linux-arm64",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-freetype/3.4.1/lwjgl-freetype-3.4.1-natives-linux-arm64.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-freetype/3.4.1/lwjgl-freetype-3.4.1-natives-linux-arm64.jar",
|
||||
"sha1": "8f37d0da3386ff602ec54cd06626881895711041",
|
||||
"size": 1309568
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl.lwjgl:lwjgl-platform:2.9.0:natives": {
|
||||
"name": "org.glavo.hmcl:lwjgl2-natives:2.9.3",
|
||||
"downloads": {
|
||||
@@ -2661,34 +2485,6 @@
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-freetype:3.3.3:natives-linux": null,
|
||||
"org.lwjgl:lwjgl:3.4.1:natives-linux": {
|
||||
"name": "org.glavo.hmcl:lwjgl3-natives:3.4.1-rc1",
|
||||
"downloads": {
|
||||
"classifiers": {
|
||||
"linux-loongarch64": {
|
||||
"path": "org/glavo/hmcl/lwjgl3-natives/3.4.1-rc1/lwjgl3-natives-3.4.1-rc1-linux-loongarch64.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/glavo/hmcl/lwjgl3-natives/3.4.1-rc1-linux-loongarch64/lwjgl3-natives-3.4.1-rc1-linux-loongarch64.jar",
|
||||
"sha1": "3fed872fc2f9929d2be25389dd312dfb48e9f89e",
|
||||
"size": 22854580
|
||||
}
|
||||
}
|
||||
},
|
||||
"extract": {
|
||||
"exclude": [
|
||||
"META-INF/"
|
||||
]
|
||||
},
|
||||
"natives": {
|
||||
"linux": "linux-loongarch64"
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-jemalloc:3.4.1:natives-linux": null,
|
||||
"org.lwjgl:lwjgl-openal:3.4.1:natives-linux": null,
|
||||
"org.lwjgl:lwjgl-opengl:3.4.1:natives-linux": null,
|
||||
"org.lwjgl:lwjgl-glfw:3.4.1:natives-linux": null,
|
||||
"org.lwjgl:lwjgl-stb:3.4.1:natives-linux": null,
|
||||
"org.lwjgl:lwjgl-tinyfd:3.4.1:natives-linux": null,
|
||||
"org.lwjgl:lwjgl-freetype:3.4.1:natives-linux": null,
|
||||
"net.java.dev.jna:jna:5.8.0": {
|
||||
"name": "net.java.dev.jna:jna:5.13.0",
|
||||
"downloads": {
|
||||
@@ -4183,182 +3979,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl:3.4.1": {
|
||||
"name": "org.lwjgl:lwjgl:3.4.1",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl/3.4.1/lwjgl-3.4.1.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl/3.4.1/lwjgl-3.4.1.jar",
|
||||
"sha1": "6105690714874b995aa7812e4f7732a21109276c",
|
||||
"size": 1157957
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl:3.4.1:natives-linux": {
|
||||
"name": "org.lwjgl:lwjgl:3.4.1:natives-linux-riscv64",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl/3.4.1/lwjgl-3.4.1-natives-linux-riscv64.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl/3.4.1/lwjgl-3.4.1-natives-linux-riscv64.jar",
|
||||
"sha1": "a43b5208883562d31b5a2de1810aa82e2f2bf0ba",
|
||||
"size": 88670
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-jemalloc:3.4.1": {
|
||||
"name": "org.lwjgl:lwjgl-jemalloc:3.4.1",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-jemalloc/3.4.1/lwjgl-jemalloc-3.4.1.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-jemalloc/3.4.1/lwjgl-jemalloc-3.4.1.jar",
|
||||
"sha1": "16b663092854fc6adfe0a941e61cae2bb2e437b6",
|
||||
"size": 47872
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-jemalloc:3.4.1:natives-linux": {
|
||||
"name": "org.lwjgl:lwjgl-jemalloc:3.4.1:natives-linux-riscv64",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-jemalloc/3.4.1/lwjgl-jemalloc-3.4.1-natives-linux-riscv64.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-jemalloc/3.4.1/lwjgl-jemalloc-3.4.1-natives-linux-riscv64.jar",
|
||||
"sha1": "ac7be1f86e87df030e668c02df2dec27c44da32b",
|
||||
"size": 216564
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-openal:3.4.1": {
|
||||
"name": "org.lwjgl:lwjgl-openal:3.4.1",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-openal/3.4.1/lwjgl-openal-3.4.1.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-openal/3.4.1/lwjgl-openal-3.4.1.jar",
|
||||
"sha1": "8508bd60589de0539aa465b78fcf838efd07ae9a",
|
||||
"size": 153919
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-openal:3.4.1:natives-linux": {
|
||||
"name": "org.lwjgl:lwjgl-openal:3.4.1:natives-linux-riscv64",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-openal/3.4.1/lwjgl-openal-3.4.1-natives-linux-riscv64.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-openal/3.4.1/lwjgl-openal-3.4.1-natives-linux-riscv64.jar",
|
||||
"sha1": "652b9424f529dccc79694f2124709083d2712104",
|
||||
"size": 829997
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-opengl:3.4.1": {
|
||||
"name": "org.lwjgl:lwjgl-opengl:3.4.1",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-opengl/3.4.1/lwjgl-opengl-3.4.1.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-opengl/3.4.1/lwjgl-opengl-3.4.1.jar",
|
||||
"sha1": "830412cab823c029cda6b9729f9d2ed36cf79959",
|
||||
"size": 937660
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-opengl:3.4.1:natives-linux": {
|
||||
"name": "org.lwjgl:lwjgl-opengl:3.4.1:natives-linux-riscv64",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-opengl/3.4.1/lwjgl-opengl-3.4.1-natives-linux-riscv64.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-opengl/3.4.1/lwjgl-opengl-3.4.1-natives-linux-riscv64.jar",
|
||||
"sha1": "8a6f47236738e3c682e98e15a13cf0358c1da85c",
|
||||
"size": 58079
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-glfw:3.4.1": {
|
||||
"name": "org.lwjgl:lwjgl-glfw:3.4.1",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-glfw/3.4.1/lwjgl-glfw-3.4.1.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-glfw/3.4.1/lwjgl-glfw-3.4.1.jar",
|
||||
"sha1": "a782b1ddd175c9107bf300fd92920579ea65e2a4",
|
||||
"size": 151893
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-glfw:3.4.1:natives-linux": {
|
||||
"name": "org.lwjgl:lwjgl-glfw:3.4.1:natives-linux-riscv64",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-glfw/3.4.1/lwjgl-glfw-3.4.1-natives-linux-riscv64.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-glfw/3.4.1/lwjgl-glfw-3.4.1-natives-linux-riscv64.jar",
|
||||
"sha1": "d76ed6846bff9804cfd1adb84b068728645a097b",
|
||||
"size": 120912
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-stb:3.4.1": {
|
||||
"name": "org.lwjgl:lwjgl-stb:3.4.1",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-stb/3.4.1/lwjgl-stb-3.4.1.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-stb/3.4.1/lwjgl-stb-3.4.1.jar",
|
||||
"sha1": "f077c3dafc31924fbe8acb0b913f08977ba27f8e",
|
||||
"size": 142927
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-stb:3.4.1:natives-linux": {
|
||||
"name": "org.lwjgl:lwjgl-stb:3.4.1:natives-linux-riscv64",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-stb/3.4.1/lwjgl-stb-3.4.1-natives-linux-riscv64.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-stb/3.4.1/lwjgl-stb-3.4.1-natives-linux-riscv64.jar",
|
||||
"sha1": "f1d8fe25d44e26c40f4dd4c48189323675467578",
|
||||
"size": 224156
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-tinyfd:3.4.1": {
|
||||
"name": "org.lwjgl:lwjgl-tinyfd:3.4.1",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-tinyfd/3.4.1/lwjgl-tinyfd-3.4.1.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-tinyfd/3.4.1/lwjgl-tinyfd-3.4.1.jar",
|
||||
"sha1": "562697d40dbd2ed0424bf24dcf65d51170f81adf",
|
||||
"size": 15931
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-tinyfd:3.4.1:natives-linux": {
|
||||
"name": "org.lwjgl:lwjgl-tinyfd:3.4.1:natives-linux-riscv64",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-tinyfd/3.4.1/lwjgl-tinyfd-3.4.1-natives-linux-riscv64.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-tinyfd/3.4.1/lwjgl-tinyfd-3.4.1-natives-linux-riscv64.jar",
|
||||
"sha1": "6aa204e5047e9f272c7271119105833cc0ddfd27",
|
||||
"size": 46650
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-freetype:3.4.1": {
|
||||
"name": "org.lwjgl:lwjgl-freetype:3.4.1",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-freetype/3.4.1/lwjgl-freetype-3.4.1.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-freetype/3.4.1/lwjgl-freetype-3.4.1.jar",
|
||||
"sha1": "caa75a37e857efc9b0686e434d708d6420c5b6ea",
|
||||
"size": 464342
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-freetype:3.4.1:natives-linux": {
|
||||
"name": "org.lwjgl:lwjgl-freetype:3.4.1:natives-linux-riscv64",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-freetype/3.4.1/lwjgl-freetype-3.4.1-natives-linux-riscv64.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-freetype/3.4.1/lwjgl-freetype-3.4.1-natives-linux-riscv64.jar",
|
||||
"sha1": "737708c27a49ba5884ef347565fcb9964e8d85a9",
|
||||
"size": 1249074
|
||||
}
|
||||
}
|
||||
},
|
||||
"com.github.oshi:oshi-core:6.6.5": {
|
||||
"name": "com.github.oshi:oshi-core:6.8.0",
|
||||
"downloads": {
|
||||
@@ -6149,182 +5769,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl:3.4.1": {
|
||||
"name": "org.lwjgl:lwjgl:3.4.1",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl/3.4.1/lwjgl-3.4.1.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl/3.4.1/lwjgl-3.4.1.jar",
|
||||
"sha1": "6105690714874b995aa7812e4f7732a21109276c",
|
||||
"size": 1157957
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl:3.4.1:natives-linux": {
|
||||
"name": "org.lwjgl:lwjgl:3.4.1:natives-freebsd",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl/3.4.1/lwjgl-3.4.1-natives-freebsd.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl/3.4.1/lwjgl-3.4.1-natives-freebsd.jar",
|
||||
"sha1": "0b1c18e52be76ce4e0a05e323e01060406887351",
|
||||
"size": 102712
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-jemalloc:3.4.1": {
|
||||
"name": "org.lwjgl:lwjgl-jemalloc:3.4.1",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-jemalloc/3.4.1/lwjgl-jemalloc-3.4.1.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-jemalloc/3.4.1/lwjgl-jemalloc-3.4.1.jar",
|
||||
"sha1": "16b663092854fc6adfe0a941e61cae2bb2e437b6",
|
||||
"size": 47872
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-jemalloc:3.4.1:natives-linux": {
|
||||
"name": "org.lwjgl:lwjgl-jemalloc:3.4.1:natives-freebsd",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-jemalloc/3.4.1/lwjgl-jemalloc-3.4.1-natives-freebsd.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-jemalloc/3.4.1/lwjgl-jemalloc-3.4.1-natives-freebsd.jar",
|
||||
"sha1": "a9565df163061a20bd3062dd7eb240d019e748b2",
|
||||
"size": 159419
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-openal:3.4.1": {
|
||||
"name": "org.lwjgl:lwjgl-openal:3.4.1",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-openal/3.4.1/lwjgl-openal-3.4.1.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-openal/3.4.1/lwjgl-openal-3.4.1.jar",
|
||||
"sha1": "8508bd60589de0539aa465b78fcf838efd07ae9a",
|
||||
"size": 153919
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-openal:3.4.1:natives-linux": {
|
||||
"name": "org.lwjgl:lwjgl-openal:3.4.1:natives-freebsd",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-openal/3.4.1/lwjgl-openal-3.4.1-natives-freebsd.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-openal/3.4.1/lwjgl-openal-3.4.1-natives-freebsd.jar",
|
||||
"sha1": "c28d721b930590df368c9503fd84f06e4a3211f5",
|
||||
"size": 830092
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-opengl:3.4.1": {
|
||||
"name": "org.lwjgl:lwjgl-opengl:3.4.1",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-opengl/3.4.1/lwjgl-opengl-3.4.1.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-opengl/3.4.1/lwjgl-opengl-3.4.1.jar",
|
||||
"sha1": "830412cab823c029cda6b9729f9d2ed36cf79959",
|
||||
"size": 937660
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-opengl:3.4.1:natives-linux": {
|
||||
"name": "org.lwjgl:lwjgl-opengl:3.4.1:natives-freebsd",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-opengl/3.4.1/lwjgl-opengl-3.4.1-natives-freebsd.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-opengl/3.4.1/lwjgl-opengl-3.4.1-natives-freebsd.jar",
|
||||
"sha1": "fdde3b33c1fb4c9329da9e741fa894266baef71f",
|
||||
"size": 81739
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-glfw:3.4.1": {
|
||||
"name": "org.lwjgl:lwjgl-glfw:3.4.1",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-glfw/3.4.1/lwjgl-glfw-3.4.1.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-glfw/3.4.1/lwjgl-glfw-3.4.1.jar",
|
||||
"sha1": "a782b1ddd175c9107bf300fd92920579ea65e2a4",
|
||||
"size": 151893
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-glfw:3.4.1:natives-linux": {
|
||||
"name": "org.lwjgl:lwjgl-glfw:3.4.1:natives-freebsd",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-glfw/3.4.1/lwjgl-glfw-3.4.1-natives-freebsd.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-glfw/3.4.1/lwjgl-glfw-3.4.1-natives-freebsd.jar",
|
||||
"sha1": "c367840595bdaa6f84830138c8b5cf59618b60fa",
|
||||
"size": 106220
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-stb:3.4.1": {
|
||||
"name": "org.lwjgl:lwjgl-stb:3.4.1",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-stb/3.4.1/lwjgl-stb-3.4.1.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-stb/3.4.1/lwjgl-stb-3.4.1.jar",
|
||||
"sha1": "f077c3dafc31924fbe8acb0b913f08977ba27f8e",
|
||||
"size": 142927
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-stb:3.4.1:natives-linux": {
|
||||
"name": "org.lwjgl:lwjgl-stb:3.4.1:natives-freebsd",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-stb/3.4.1/lwjgl-stb-3.4.1-natives-freebsd.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-stb/3.4.1/lwjgl-stb-3.4.1-natives-freebsd.jar",
|
||||
"sha1": "299c873b02718f5a11bc31279189d434a7279c15",
|
||||
"size": 224821
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-tinyfd:3.4.1": {
|
||||
"name": "org.lwjgl:lwjgl-tinyfd:3.4.1",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-tinyfd/3.4.1/lwjgl-tinyfd-3.4.1.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-tinyfd/3.4.1/lwjgl-tinyfd-3.4.1.jar",
|
||||
"sha1": "562697d40dbd2ed0424bf24dcf65d51170f81adf",
|
||||
"size": 15931
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-tinyfd:3.4.1:natives-linux": {
|
||||
"name": "org.lwjgl:lwjgl-tinyfd:3.4.1:natives-freebsd",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-tinyfd/3.4.1/lwjgl-tinyfd-3.4.1-natives-freebsd.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-tinyfd/3.4.1/lwjgl-tinyfd-3.4.1-natives-freebsd.jar",
|
||||
"sha1": "c7cabb0cf65ab1025667335bf4e4df3af9ef4e01",
|
||||
"size": 40471
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-freetype:3.4.1": {
|
||||
"name": "org.lwjgl:lwjgl-freetype:3.4.1",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-freetype/3.4.1/lwjgl-freetype-3.4.1.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-freetype/3.4.1/lwjgl-freetype-3.4.1.jar",
|
||||
"sha1": "caa75a37e857efc9b0686e434d708d6420c5b6ea",
|
||||
"size": 464342
|
||||
}
|
||||
}
|
||||
},
|
||||
"org.lwjgl:lwjgl-freetype:3.4.1:natives-linux": {
|
||||
"name": "org.lwjgl:lwjgl-freetype:3.4.1:natives-freebsd",
|
||||
"downloads": {
|
||||
"artifact": {
|
||||
"path": "org/lwjgl/lwjgl-freetype/3.4.1/lwjgl-freetype-3.4.1-natives-freebsd.jar",
|
||||
"url": "https://repo1.maven.org/maven2/org/lwjgl/lwjgl-freetype/3.4.1/lwjgl-freetype-3.4.1-natives-freebsd.jar",
|
||||
"sha1": "d7e622ab389bb8549617b0b20db5824b7b2e262b",
|
||||
"size": 1217256
|
||||
}
|
||||
}
|
||||
},
|
||||
"net.java.jinput:jinput-platform:2.0.5:natives": null,
|
||||
"com.mojang:text2speech:1.10.3:natives": null,
|
||||
"com.mojang:text2speech:1.11.3:natives": null,
|
||||
|
||||
+1
-3
@@ -59,15 +59,13 @@ public class AuthlibInjectorServer implements Observable {
|
||||
try {
|
||||
url = NetworkUtils.addHttpsIfMissing(url);
|
||||
HttpURLConnection conn = NetworkUtils.createHttpConnection(url);
|
||||
conn = NetworkUtils.resolveConnection(conn);
|
||||
|
||||
String ali = conn.getHeaderField("x-authlib-injector-api-location");
|
||||
if (ali != null) {
|
||||
URI absoluteAli = conn.getURL().toURI().resolve(NetworkUtils.toURI(ali));
|
||||
if (!urlEqualsIgnoreSlash(url, absoluteAli.toString())) {
|
||||
conn.disconnect();
|
||||
url = absoluteAli.toString();
|
||||
conn = NetworkUtils.resolveConnection(NetworkUtils.createHttpConnection(absoluteAli));
|
||||
conn = NetworkUtils.createHttpConnection(absoluteAli);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,12 +93,13 @@ public final class BMCLAPIDownloadProvider implements DownloadProvider {
|
||||
pair("https://repo.maven.apache.org/maven2", "https://mirrors.cloud.tencent.com/nexus/repository/maven-public"),
|
||||
pair("https://hmcl.glavo.site/metadata/cleanroom", "https://alist.8mi.tech/d/mirror/HMCL-Metadata/Auto/cleanroom"),
|
||||
pair("https://hmcl.glavo.site/metadata/fmllibs", "https://alist.8mi.tech/d/mirror/HMCL-Metadata/Auto/fmllibs"),
|
||||
pair("https://zkitefly.github.io/unlisted-versions-of-minecraft", "https://alist.8mi.tech/d/mirror/unlisted-versions-of-minecraft/Auto"),
|
||||
// https://github.com/mcmod-info-mirror/mcim-rust-api
|
||||
pair("https://api.modrinth.com", "https://mod.mcimirror.top/modrinth"),
|
||||
pair("https://cdn.modrinth.com", "https://mod.mcimirror.top"),
|
||||
pair("https://api.curseforge.com", "https://mod.mcimirror.top/curseforge"),
|
||||
pair("https://edge.forgecdn.net", "https://mod.mcimirror.top")
|
||||
pair("https://zkitefly.github.io/unlisted-versions-of-minecraft", "https://alist.8mi.tech/d/mirror/unlisted-versions-of-minecraft/Auto")
|
||||
// // https://github.com/mcmod-info-mirror/mcim-rust-api
|
||||
// pair("https://api.modrinth.com", "https://mod.mcimirror.top/modrinth"),
|
||||
// pair("https://cdn.modrinth.com", "https://mod.mcimirror.top"),
|
||||
// pair("https://api.curseforge.com", "https://mod.mcimirror.top/curseforge"),
|
||||
// pair("https://edge.forgecdn.net", "https://mod.mcimirror.top"),
|
||||
// pair("https://mediafilez.forgecdn.net", "https://mod.mcimirror.top")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.jackhuang.hmcl.task.Task;
|
||||
import org.jackhuang.hmcl.util.function.ExceptionalFunction;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -42,28 +43,28 @@ public class DefaultGameBuilder extends GameBuilder {
|
||||
|
||||
@Override
|
||||
public Task<?> buildAsync() {
|
||||
var hints = new ArrayList<Task.StagesHint>();
|
||||
List<String> stages = new ArrayList<>();
|
||||
|
||||
Task<Version> libraryTask = Task.supplyAsync(() -> new Version(name));
|
||||
libraryTask = libraryTask.thenComposeAsync(libraryTaskHelper(gameVersion, "game", gameVersion));
|
||||
hints.add(new Task.StagesHint("hmcl.install.game:" + gameVersion));
|
||||
hints.add(new Task.StagesHint("hmcl.install.libraries"));
|
||||
hints.add(new Task.StagesHint("hmcl.install.assets"));
|
||||
stages.add("hmcl.install.game:" + gameVersion);
|
||||
stages.add("hmcl.install.libraries");
|
||||
stages.add("hmcl.install.assets");
|
||||
|
||||
for (Map.Entry<String, String> entry : toolVersions.entrySet()) {
|
||||
libraryTask = libraryTask.thenComposeAsync(libraryTaskHelper(gameVersion, entry.getKey(), entry.getValue()));
|
||||
hints.add(new Task.StagesHint(String.format("hmcl.install.%s:%s", entry.getKey(), entry.getValue())));
|
||||
stages.add(String.format("hmcl.install.%s:%s", entry.getKey(), entry.getValue()));
|
||||
}
|
||||
|
||||
for (RemoteVersion remoteVersion : remoteVersions) {
|
||||
libraryTask = libraryTask.thenComposeAsync(version -> dependencyManager.installLibraryAsync(version, remoteVersion));
|
||||
hints.add(new Task.StagesHint(String.format("hmcl.install.%s:%s", remoteVersion.getLibraryId(), remoteVersion.getSelfVersion())));
|
||||
stages.add(String.format("hmcl.install.%s:%s", remoteVersion.getLibraryId(), remoteVersion.getSelfVersion()));
|
||||
}
|
||||
|
||||
return libraryTask.thenComposeAsync(dependencyManager.getGameRepository()::saveAsync).whenComplete(exception -> {
|
||||
if (exception != null)
|
||||
dependencyManager.getGameRepository().removeVersionFromDisk(name);
|
||||
}).withStagesHints(hints);
|
||||
}).withStagesHint(stages);
|
||||
}
|
||||
|
||||
private ExceptionalFunction<Version, Task<Version>, ?> libraryTaskHelper(String gameVersion, String libraryId, String libraryVersion) {
|
||||
|
||||
@@ -20,7 +20,6 @@ package org.jackhuang.hmcl.game;
|
||||
|
||||
import com.sun.tools.attach.AttachNotSupportedException;
|
||||
import com.sun.tools.attach.VirtualMachine;
|
||||
import org.jackhuang.hmcl.java.JavaInfo;
|
||||
import org.jackhuang.hmcl.util.logging.Logger;
|
||||
import org.jackhuang.hmcl.util.StringUtils;
|
||||
import org.jackhuang.hmcl.util.platform.OperatingSystem;
|
||||
@@ -129,20 +128,7 @@ public final class GameDumpGenerator {
|
||||
}
|
||||
|
||||
private static void writeDumpBodyTo(VirtualMachine vm, Writer writer) throws IOException {
|
||||
int vmVersion = -1;
|
||||
|
||||
try {
|
||||
if (vm.getSystemProperties().get("java.version") instanceof String javaVersion)
|
||||
vmVersion = JavaInfo.parseVersion(javaVersion);
|
||||
} catch (Throwable e) {
|
||||
LOG.warning("Failed to get VM system properties", e);
|
||||
}
|
||||
|
||||
if (vmVersion >= 11)
|
||||
execute(vm, "Thread.print -e -l", writer);
|
||||
else
|
||||
execute(vm, "Thread.print -l", writer);
|
||||
|
||||
execute(vm, "Thread.print -e -l", writer);
|
||||
}
|
||||
|
||||
private static VirtualMachine attachVM(String lvmid, Writer writer) throws IOException, InterruptedException {
|
||||
|
||||
@@ -34,7 +34,6 @@ import java.nio.channels.OverlappingFileLockException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.*;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
@@ -45,18 +44,10 @@ public final class World {
|
||||
|
||||
private final Path file;
|
||||
private String fileName;
|
||||
private Image icon;
|
||||
|
||||
private CompoundTag levelData;
|
||||
private Image icon;
|
||||
private Path levelDataPath;
|
||||
|
||||
private CompoundTag worldGenSettingsDataBackingTag; // Use for writing back to the file
|
||||
private CompoundTag normalizedWorldGenSettingsData; // Use for reading/modification
|
||||
private Path worldGenSettingsDataPath;
|
||||
|
||||
private CompoundTag playerData; // Use for both reading/modification and writing back to the file
|
||||
private Path playerDataPath;
|
||||
|
||||
public World(Path file) throws IOException {
|
||||
this.file = file;
|
||||
|
||||
@@ -85,10 +76,14 @@ public final class World {
|
||||
public void setWorldName(String worldName) throws IOException {
|
||||
if (levelData.get("Data") instanceof CompoundTag data && data.get("LevelName") instanceof StringTag levelNameTag) {
|
||||
levelNameTag.setValue(worldName);
|
||||
writeLevelData();
|
||||
writeLevelDat(levelData);
|
||||
}
|
||||
}
|
||||
|
||||
public Path getLevelDatFile() {
|
||||
return file.resolve("level.dat");
|
||||
}
|
||||
|
||||
public Path getSessionLockFile() {
|
||||
return file.resolve("session.lock");
|
||||
}
|
||||
@@ -97,14 +92,6 @@ public final class World {
|
||||
return levelData;
|
||||
}
|
||||
|
||||
public @Nullable CompoundTag getNormalizedWorldGenSettingsData() {
|
||||
return normalizedWorldGenSettingsData;
|
||||
}
|
||||
|
||||
public @Nullable CompoundTag getPlayerData() {
|
||||
return playerData;
|
||||
}
|
||||
|
||||
public long getLastPlayed() {
|
||||
CompoundTag data = levelData.get("Data");
|
||||
LongTag lastPlayedTag = data.get("LastPlayed");
|
||||
@@ -121,12 +108,10 @@ public final class World {
|
||||
}
|
||||
|
||||
public @Nullable Long getSeed() {
|
||||
// Valid after 1.16(20w20a)
|
||||
if (normalizedWorldGenSettingsData != null && normalizedWorldGenSettingsData.get("seed") instanceof LongTag seedTag) {
|
||||
CompoundTag data = levelData.get("Data");
|
||||
if (data.get("WorldGenSettings") instanceof CompoundTag worldGenSettingsTag && worldGenSettingsTag.get("seed") instanceof LongTag seedTag) { //Valid after 1.16
|
||||
return seedTag.getValue();
|
||||
}
|
||||
// Valid before 1.16(20w20a)
|
||||
if (levelData.get("Data") instanceof CompoundTag data && data.get("RandomSeed") instanceof LongTag seedTag) {
|
||||
} else if (data.get("RandomSeed") instanceof LongTag seedTag) { //Valid before 1.16
|
||||
return seedTag.getValue();
|
||||
}
|
||||
return null;
|
||||
@@ -134,28 +119,22 @@ public final class World {
|
||||
|
||||
public boolean isLargeBiomes() {
|
||||
CompoundTag data = levelData.get("Data");
|
||||
|
||||
// Valid before 1.16(20w20a)
|
||||
if (data.get("generatorName") instanceof StringTag generatorNameTag) {
|
||||
if (data.get("generatorName") instanceof StringTag generatorNameTag) { //Valid before 1.16
|
||||
return "largeBiomes".equals(generatorNameTag.getValue());
|
||||
}
|
||||
// Unified handling of logic after version 1.16
|
||||
else if (normalizedWorldGenSettingsData != null
|
||||
&& normalizedWorldGenSettingsData.get("dimensions") instanceof CompoundTag dimensionsTag) {
|
||||
if (dimensionsTag.get("minecraft:overworld") instanceof CompoundTag overworldTag
|
||||
} else {
|
||||
if (data.get("WorldGenSettings") instanceof CompoundTag worldGenSettingsTag
|
||||
&& worldGenSettingsTag.get("dimensions") instanceof CompoundTag dimensionsTag
|
||||
&& dimensionsTag.get("minecraft:overworld") instanceof CompoundTag overworldTag
|
||||
&& overworldTag.get("generator") instanceof CompoundTag generatorTag) {
|
||||
// Valid between 1.16(20w20a) and 1.18(21w37a)
|
||||
if (generatorTag.get("biome_source") instanceof CompoundTag biomeSourceTag
|
||||
&& biomeSourceTag.get("large_biomes") instanceof ByteTag largeBiomesTag) {
|
||||
&& biomeSourceTag.get("large_biomes") instanceof ByteTag largeBiomesTag) { //Valid between 1.16 and 1.16.2
|
||||
return largeBiomesTag.getValue() == (byte) 1;
|
||||
}
|
||||
// Valid after 1.18(21w37a)
|
||||
else if (generatorTag.get("settings") instanceof StringTag settingsTag) {
|
||||
} else if (generatorTag.get("settings") instanceof StringTag settingsTag) { //Valid after 1.16.2
|
||||
return "minecraft:large_biomes".equals(settingsTag.getValue());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Image getIcon() {
|
||||
@@ -187,8 +166,8 @@ public final class World {
|
||||
if (!Files.exists(levelDat)) {
|
||||
throw new IOException("Not a valid world directory since level.dat or special_level.dat cannot be found.");
|
||||
}
|
||||
loadAndCheckLevelDat(levelDat);
|
||||
this.levelDataPath = levelDat;
|
||||
loadAndCheckWorldData();
|
||||
|
||||
Path iconFile = file.resolve("icon.png");
|
||||
if (Files.isRegularFile(iconFile)) {
|
||||
@@ -210,7 +189,7 @@ public final class World {
|
||||
if (!Files.exists(levelDat)) {
|
||||
throw new IOException("Not a valid world zip file since level.dat or special_level.dat cannot be found.");
|
||||
}
|
||||
loadAndCheckLevelData(levelDat);
|
||||
loadAndCheckLevelDat(levelDat);
|
||||
|
||||
Path iconFile = root.resolve("icon.png");
|
||||
if (Files.isRegularFile(iconFile)) {
|
||||
@@ -242,13 +221,8 @@ public final class World {
|
||||
}
|
||||
}
|
||||
|
||||
private void loadAndCheckWorldData() throws IOException {
|
||||
loadAndCheckLevelData(levelDataPath);
|
||||
loadOtherData();
|
||||
}
|
||||
|
||||
private void loadAndCheckLevelData(Path levelDat) throws IOException {
|
||||
this.levelData = readTag(levelDat);
|
||||
private void loadAndCheckLevelDat(Path levelDat) throws IOException {
|
||||
this.levelData = parseLevelDat(levelDat);
|
||||
CompoundTag data = levelData.get("Data");
|
||||
if (data == null)
|
||||
throw new IOException("level.dat missing Data");
|
||||
@@ -260,54 +234,10 @@ public final class World {
|
||||
throw new IOException("level.dat missing LastPlayed");
|
||||
}
|
||||
|
||||
private void loadOtherData() throws IOException {
|
||||
if (!(levelData.get("Data") instanceof CompoundTag data)) return;
|
||||
|
||||
Path worldGenSettingsDatPath = file.resolve("data/minecraft/world_gen_settings.dat");
|
||||
if (data.get("WorldGenSettings") instanceof CompoundTag worldGenSettingsTag) {
|
||||
setWorldGenSettingsData(null, worldGenSettingsTag, worldGenSettingsTag);
|
||||
} else if (Files.isRegularFile(worldGenSettingsDatPath)) {
|
||||
CompoundTag raw = readTag(worldGenSettingsDatPath);
|
||||
if (raw.get("data") instanceof CompoundTag compoundTag) {
|
||||
setWorldGenSettingsData(worldGenSettingsDatPath, raw, compoundTag);
|
||||
} else {
|
||||
setWorldGenSettingsData(null, null, null);
|
||||
}
|
||||
} else {
|
||||
setWorldGenSettingsData(null, null, null);
|
||||
public void reloadLevelDat() throws IOException {
|
||||
if (levelDataPath != null) {
|
||||
loadAndCheckLevelDat(this.levelDataPath);
|
||||
}
|
||||
|
||||
if (data.get("Player") instanceof CompoundTag playerTag) {
|
||||
setPlayerData(null, playerTag);
|
||||
} else if (data.get("singleplayer_uuid") instanceof IntArrayTag uuidTag && uuidTag.getValue().length == 4) {
|
||||
int[] uuidValue = uuidTag.getValue();
|
||||
long mostSigBits = ((long) uuidValue[0] << 32) | (uuidValue[1] & 0xFFFFFFFFL);
|
||||
long leastSigBits = ((long) uuidValue[2] << 32) | (uuidValue[3] & 0xFFFFFFFFL);
|
||||
String playerUUID = new UUID(mostSigBits, leastSigBits).toString();
|
||||
Path playerDatPath = file.resolve("players/data/" + playerUUID + ".dat");
|
||||
if (Files.exists(playerDatPath)) {
|
||||
setPlayerData(playerDatPath, readTag(playerDatPath));
|
||||
} else {
|
||||
setPlayerData(null, null);
|
||||
}
|
||||
} else {
|
||||
setPlayerData(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void setWorldGenSettingsData(Path worldGenSettingsDataPath, CompoundTag worldGenSettingsDataBackingTag, CompoundTag unifiedWorldGenSettingsData) {
|
||||
this.worldGenSettingsDataPath = worldGenSettingsDataPath;
|
||||
this.worldGenSettingsDataBackingTag = worldGenSettingsDataBackingTag;
|
||||
this.normalizedWorldGenSettingsData = unifiedWorldGenSettingsData;
|
||||
}
|
||||
|
||||
private void setPlayerData(Path playerDataPath, CompoundTag playerData) {
|
||||
this.playerDataPath = playerDataPath;
|
||||
this.playerData = playerData;
|
||||
}
|
||||
|
||||
public void reloadWorldData() throws IOException {
|
||||
loadAndCheckWorldData();
|
||||
}
|
||||
|
||||
// The rename method is used to rename temporary world object during installation and copying,
|
||||
@@ -319,7 +249,7 @@ public final class World {
|
||||
// Change the name recorded in level.dat
|
||||
CompoundTag data = levelData.get("Data");
|
||||
data.put(new StringTag("LevelName", newName));
|
||||
writeLevelData();
|
||||
writeLevelDat(levelData);
|
||||
|
||||
// then change the folder's name
|
||||
Files.move(file, file.resolveSibling(newName));
|
||||
@@ -415,41 +345,27 @@ public final class World {
|
||||
}
|
||||
}
|
||||
|
||||
public void writeWorldData() throws IOException {
|
||||
if (!Files.isDirectory(file)) throw new IOException("Not a valid world directory");
|
||||
public void writeLevelDat(CompoundTag nbt) throws IOException {
|
||||
if (!Files.isDirectory(file))
|
||||
throw new IOException("Not a valid world directory");
|
||||
|
||||
writeLevelData();
|
||||
|
||||
if (worldGenSettingsDataPath != null && worldGenSettingsDataBackingTag != null) {
|
||||
writeTag(worldGenSettingsDataBackingTag, worldGenSettingsDataPath);
|
||||
}
|
||||
|
||||
if (playerDataPath != null && playerData != null) {
|
||||
writeTag(playerData, playerDataPath);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeLevelData() throws IOException {
|
||||
writeTag(levelData, levelDataPath);
|
||||
}
|
||||
|
||||
private CompoundTag readTag(Path path) throws IOException {
|
||||
try (InputStream is = new GZIPInputStream(Files.newInputStream(path))) {
|
||||
Tag tag = NBTIO.readTag(is);
|
||||
if (tag instanceof CompoundTag compoundTag) return compoundTag;
|
||||
throw new IOException("NBT file malformed: " + path);
|
||||
}
|
||||
}
|
||||
|
||||
private void writeTag(CompoundTag nbt, Path path) throws IOException {
|
||||
if (!Files.isDirectory(file)) throw new IOException("Not a valid world directory");
|
||||
FileUtils.saveSafely(path, os -> {
|
||||
FileUtils.saveSafely(getLevelDatFile(), os -> {
|
||||
try (OutputStream gos = new GZIPOutputStream(os)) {
|
||||
NBTIO.writeTag(gos, nbt);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static CompoundTag parseLevelDat(Path path) throws IOException {
|
||||
try (InputStream is = new GZIPInputStream(Files.newInputStream(path))) {
|
||||
Tag nbt = NBTIO.readTag(is);
|
||||
if (nbt instanceof CompoundTag compoundTag)
|
||||
return compoundTag;
|
||||
else
|
||||
throw new IOException("level.dat malformed");
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isLocked(Path sessionLockFile) {
|
||||
try (FileChannel fileChannel = FileChannel.open(sessionLockFile, StandardOpenOption.WRITE)) {
|
||||
return fileChannel.tryLock() == null;
|
||||
@@ -466,17 +382,14 @@ public final class World {
|
||||
public static List<World> getWorlds(Path savesDir) {
|
||||
if (Files.exists(savesDir)) {
|
||||
try (Stream<Path> stream = Files.list(savesDir)) {
|
||||
return stream
|
||||
.filter(Files::isDirectory)
|
||||
.flatMap(world -> {
|
||||
try {
|
||||
return Stream.of(new World(world.toAbsolutePath().normalize()));
|
||||
} catch (IOException e) {
|
||||
LOG.warning("Failed to read world " + world, e);
|
||||
return Stream.empty();
|
||||
}
|
||||
})
|
||||
.toList();
|
||||
return stream.flatMap(world -> {
|
||||
try {
|
||||
return Stream.of(new World(world.toAbsolutePath().normalize()));
|
||||
} catch (IOException e) {
|
||||
LOG.warning("Failed to read world " + world, e);
|
||||
return Stream.empty();
|
||||
}
|
||||
}).toList();
|
||||
} catch (IOException e) {
|
||||
LOG.warning("Failed to read saves", e);
|
||||
}
|
||||
|
||||
@@ -650,10 +650,8 @@ public class DefaultLauncher extends Launcher {
|
||||
final String command = usePowerShell ? null : commandLine.commandLine.toString();
|
||||
Map<String, String> envVars = getEnvVars();
|
||||
|
||||
if (isWindows && !usePowerShell) {
|
||||
// https://stackoverflow.com/a/28452546
|
||||
// https://learn.microsoft.com/troubleshoot/windows-client/shell-experience/command-line-string-limitation
|
||||
if (command.length() > 32767) {
|
||||
if (!usePowerShell && isWindows) {
|
||||
if (command.length() > 8192) { // maximum length of the command in cmd
|
||||
throw new CommandTooLongException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import org.jackhuang.hmcl.util.gson.JsonUtils;
|
||||
import org.jackhuang.hmcl.util.io.CompressingUtils;
|
||||
import org.jackhuang.hmcl.util.io.FileUtils;
|
||||
import org.jackhuang.hmcl.util.io.Unzipper;
|
||||
import org.jackhuang.hmcl.util.versioning.GameVersionNumber;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.*;
|
||||
@@ -58,7 +57,7 @@ public class Datapack {
|
||||
return packs;
|
||||
}
|
||||
|
||||
public static void installPack(Path sourceDatapackPath, Path targetDatapackDirectory, GameVersionNumber gameVersionNumber) throws IOException {
|
||||
public static void installPack(Path sourceDatapackPath, Path targetDatapackDirectory) throws IOException {
|
||||
boolean containsMultiplePacks;
|
||||
Set<String> packs = new HashSet<>();
|
||||
try (FileSystem fs = CompressingUtils.readonly(sourceDatapackPath).setAutoDetectEncoding(true).build()) {
|
||||
@@ -107,19 +106,7 @@ public class Datapack {
|
||||
.setSubDirectory("/datapacks/")
|
||||
.unzip();
|
||||
|
||||
Path targetResourceZipPath;
|
||||
// When the version cannot be obtained, the old version logic is used by default.
|
||||
boolean useNewResourcePath = gameVersionNumber != null
|
||||
&& gameVersionNumber.compareTo("26.1-snapshot-6") >= 0;
|
||||
|
||||
if (useNewResourcePath) {
|
||||
Files.createDirectories(targetDatapackDirectory.getParent().resolve("resourcepacks"));
|
||||
targetResourceZipPath = targetDatapackDirectory.getParent().resolve("resourcepacks/resources.zip");
|
||||
} else {
|
||||
targetResourceZipPath = targetDatapackDirectory.getParent().resolve("resources.zip");
|
||||
}
|
||||
|
||||
try (FileSystem outputResourcesZipFS = CompressingUtils.createWritableZipFileSystem(targetResourceZipPath);
|
||||
try (FileSystem outputResourcesZipFS = CompressingUtils.createWritableZipFileSystem(targetDatapackDirectory.getParent().resolve("resources.zip"));
|
||||
FileSystem inputPackZipFS = CompressingUtils.createReadOnlyZipFileSystem(sourceDatapackPath)) {
|
||||
Path resourcesZip = inputPackZipFS.getPath("resources.zip");
|
||||
if (Files.isRegularFile(resourcesZip)) {
|
||||
@@ -151,8 +138,8 @@ public class Datapack {
|
||||
}
|
||||
}
|
||||
|
||||
public void installPack(Path sourcePackPath, GameVersionNumber gameVersionNumber) throws IOException {
|
||||
installPack(sourcePackPath, path, gameVersionNumber);
|
||||
public void installPack(Path sourcePackPath) throws IOException {
|
||||
installPack(sourcePackPath, path);
|
||||
loadFromDir();
|
||||
}
|
||||
|
||||
|
||||
@@ -210,7 +210,6 @@ public class ModpackExportInfo {
|
||||
}
|
||||
|
||||
public static class Options {
|
||||
private boolean requireAuthor;
|
||||
private boolean requireUrl;
|
||||
private boolean requireForceUpdate;
|
||||
private boolean requireFileApi;
|
||||
@@ -226,10 +225,6 @@ public class ModpackExportInfo {
|
||||
public Options() {
|
||||
}
|
||||
|
||||
public boolean isRequireAuthor() {
|
||||
return requireAuthor;
|
||||
}
|
||||
|
||||
public boolean isRequireUrl() {
|
||||
return requireUrl;
|
||||
}
|
||||
@@ -274,11 +269,6 @@ public class ModpackExportInfo {
|
||||
return requireSkipCurseForgeRemoteFiles;
|
||||
}
|
||||
|
||||
public Options requireAuthor() {
|
||||
requireAuthor = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Options requireUrl() {
|
||||
requireUrl = true;
|
||||
return this;
|
||||
|
||||
@@ -115,19 +115,19 @@ public final class CurseCompletionTask extends Task<Void> {
|
||||
// Because in China, Curse is too difficult to visit,
|
||||
// if failed, ignore it and retry next time.
|
||||
CurseManifest newManifest = manifest.setFiles(
|
||||
manifest.files().parallelStream()
|
||||
manifest.getFiles().parallelStream()
|
||||
.map(file -> {
|
||||
updateProgress(finished.incrementAndGet(), manifest.files().size());
|
||||
if (StringUtils.isBlank(file.fileName()) || file.url() == null) {
|
||||
updateProgress(finished.incrementAndGet(), manifest.getFiles().size());
|
||||
if (StringUtils.isBlank(file.getFileName()) || file.getUrl() == null) {
|
||||
try {
|
||||
RemoteMod.File remoteFile = CurseForgeRemoteModRepository.MODS.getModFile(Integer.toString(file.projectID()), Integer.toString(file.fileID()));
|
||||
RemoteMod.File remoteFile = CurseForgeRemoteModRepository.MODS.getModFile(Integer.toString(file.getProjectID()), Integer.toString(file.getFileID()));
|
||||
return file.withFileName(remoteFile.getFilename()).withURL(remoteFile.getUrl());
|
||||
} catch (FileNotFoundException fof) {
|
||||
LOG.warning("Could not query api.curseforge.com for deleted mods: " + file.projectID() + ", " + file.fileID(), fof);
|
||||
LOG.warning("Could not query api.curseforge.com for deleted mods: " + file.getProjectID() + ", " + file.getFileID(), fof);
|
||||
notFound.set(true);
|
||||
return file;
|
||||
} catch (IOException | JsonParseException e) {
|
||||
LOG.warning("Unable to fetch the file name projectID=" + file.projectID() + ", fileID=" + file.fileID(), e);
|
||||
LOG.warning("Unable to fetch the file name projectID=" + file.getProjectID() + ", fileID=" + file.getFileID(), e);
|
||||
allNameKnown.set(false);
|
||||
return file;
|
||||
}
|
||||
@@ -142,9 +142,9 @@ public final class CurseCompletionTask extends Task<Void> {
|
||||
Path resourcePacksRoot = versionRoot.resolve("resourcepacks");
|
||||
Path shaderPacksRoot = versionRoot.resolve("shaderpacks");
|
||||
finished.set(0);
|
||||
dependencies = newManifest.files()
|
||||
dependencies = newManifest.getFiles()
|
||||
.stream().parallel()
|
||||
.filter(f -> f.fileName() != null)
|
||||
.filter(f -> f.getFileName() != null)
|
||||
.flatMap(f -> {
|
||||
try {
|
||||
Path path = guessFilePath(f, resourcePacksRoot, shaderPacksRoot);
|
||||
@@ -152,15 +152,15 @@ public final class CurseCompletionTask extends Task<Void> {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
var task = new FileDownloadTask(f.url(), path);
|
||||
var task = new FileDownloadTask(f.getUrl(), path);
|
||||
task.setCacheRepository(dependency.getCacheRepository());
|
||||
task.setCaching(true);
|
||||
return Stream.of(task.withCounter("hmcl.modpack.download"));
|
||||
} catch (IOException e) {
|
||||
LOG.warning("Could not query api.curseforge.com for mod: " + f.projectID() + ", " + f.fileID(), e);
|
||||
LOG.warning("Could not query api.curseforge.com for mod: " + f.getProjectID() + ", " + f.getFileID(), e);
|
||||
return Stream.empty(); // Ignore this file.
|
||||
} finally {
|
||||
updateProgress(finished.incrementAndGet(), newManifest.files().size());
|
||||
updateProgress(finished.incrementAndGet(), newManifest.getFiles().size());
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
@@ -181,9 +181,9 @@ public final class CurseCompletionTask extends Task<Void> {
|
||||
* @throws IOException If IOException was encountered during getting data from CurseForge.
|
||||
*/
|
||||
private Path guessFilePath(CurseManifestFile file, Path resourcePacksRoot, Path shaderPacksRoot) throws IOException {
|
||||
RemoteMod mod = CurseForgeRemoteModRepository.MODS.getModById(Integer.toString(file.projectID()));
|
||||
RemoteMod mod = CurseForgeRemoteModRepository.MODS.getModById(Integer.toString(file.getProjectID()));
|
||||
int classID = ((CurseAddon) mod.getData()).getClassId();
|
||||
String fileName = file.fileName();
|
||||
String fileName = file.getFileName();
|
||||
return switch (classID) {
|
||||
case 12, // Resource pack
|
||||
6552 -> { // Shader pack
|
||||
|
||||
+4
-30
@@ -33,7 +33,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
@@ -43,7 +42,6 @@ import java.util.stream.Stream;
|
||||
import static org.jackhuang.hmcl.util.Lang.mapOf;
|
||||
import static org.jackhuang.hmcl.util.Pair.pair;
|
||||
import static org.jackhuang.hmcl.util.gson.JsonUtils.listTypeOf;
|
||||
import static org.jackhuang.hmcl.util.logging.Logger.LOG;
|
||||
|
||||
public final class CurseForgeRemoteModRepository implements RemoteModRepository {
|
||||
|
||||
@@ -133,34 +131,10 @@ public final class CurseForgeRemoteModRepository implements RemoteModRepository
|
||||
query.put("index", Integer.toString(pageOffset * pageSize));
|
||||
query.put("pageSize", Integer.toString(pageSize));
|
||||
|
||||
Response<List<CurseAddon>> response = null;
|
||||
|
||||
IOException exception = null;
|
||||
List<URI> candidates = downloadProvider.injectURLWithCandidates(NetworkUtils.withQuery(PREFIX + "/v1/mods/search", query));
|
||||
for (URI candidate : candidates) {
|
||||
LOG.info("Fetching " + candidate);
|
||||
try {
|
||||
response = withApiKey(HttpRequest.GET(candidate.toString()))
|
||||
.getJson(Response.typeOf(listTypeOf(CurseAddon.class)));
|
||||
if (searchFilter.isEmpty()) {
|
||||
return new SearchResult(response.getData().stream().map(CurseAddon::toMod), calculateTotalPages(response, pageSize));
|
||||
}
|
||||
break;
|
||||
} catch (IOException e) {
|
||||
LOG.warning("Failed to search addons: " + candidate, e);
|
||||
if (candidates.size() == 1) {
|
||||
exception = e;
|
||||
} else {
|
||||
if (exception == null) {
|
||||
exception = new IOException("Failed to search addons");
|
||||
}
|
||||
exception.addSuppressed(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (response == null) {
|
||||
throw exception != null ? exception : new IOException("No candidates found");
|
||||
Response<List<CurseAddon>> response = withApiKey(HttpRequest.GET(downloadProvider.injectURL(NetworkUtils.withQuery(PREFIX + "/v1/mods/search", query))))
|
||||
.getJson(Response.typeOf(listTypeOf(CurseAddon.class)));
|
||||
if (searchFilter.isEmpty()) {
|
||||
return new SearchResult(response.getData().stream().map(CurseAddon::toMod), calculateTotalPages(response, pageSize));
|
||||
}
|
||||
|
||||
// https://github.com/HMCL-dev/HMCL/issues/1549
|
||||
|
||||
@@ -73,14 +73,14 @@ public final class CurseInstallTask extends Task<Void> {
|
||||
if (repository.hasVersion(name) && Files.notExists(json))
|
||||
throw new IllegalArgumentException("Version " + name + " already exists.");
|
||||
|
||||
GameBuilder builder = dependencyManager.gameBuilder().name(name).gameVersion(manifest.minecraft().gameVersion());
|
||||
for (CurseManifestModLoader modLoader : manifest.minecraft().modLoaders()) {
|
||||
if (modLoader.id().startsWith("forge-")) {
|
||||
builder.version("forge", modLoader.id().substring("forge-".length()));
|
||||
} else if (modLoader.id().startsWith("fabric-")) {
|
||||
builder.version("fabric", modLoader.id().substring("fabric-".length()));
|
||||
} else if (modLoader.id().startsWith("neoforge-")) {
|
||||
builder.version("neoforge", modLoader.id().substring("neoforge-".length()));
|
||||
GameBuilder builder = dependencyManager.gameBuilder().name(name).gameVersion(manifest.getMinecraft().getGameVersion());
|
||||
for (CurseManifestModLoader modLoader : manifest.getMinecraft().getModLoaders()) {
|
||||
if (modLoader.getId().startsWith("forge-")) {
|
||||
builder.version("forge", modLoader.getId().substring("forge-".length()));
|
||||
} else if (modLoader.getId().startsWith("fabric-")) {
|
||||
builder.version("fabric", modLoader.getId().substring("fabric-".length()));
|
||||
} else if (modLoader.getId().startsWith("neoforge-")) {
|
||||
builder.version("neoforge", modLoader.getId().substring("neoforge-".length()));
|
||||
}
|
||||
}
|
||||
dependents.add(builder.buildAsync());
|
||||
@@ -105,8 +105,8 @@ public final class CurseInstallTask extends Task<Void> {
|
||||
} catch (JsonParseException | IOException ignore) {
|
||||
}
|
||||
this.config = config;
|
||||
dependents.add(new ModpackInstallTask<>(zipFile, run, modpack.getEncoding(), Collections.singletonList(manifest.overrides()), any -> true, config).withStage("hmcl.modpack"));
|
||||
dependents.add(new MinecraftInstanceTask<>(zipFile, modpack.getEncoding(), Collections.singletonList(manifest.overrides()), manifest, CurseModpackProvider.INSTANCE, manifest.name(), manifest.version(), repository.getModpackConfiguration(name)).withStage("hmcl.modpack"));
|
||||
dependents.add(new ModpackInstallTask<>(zipFile, run, modpack.getEncoding(), Collections.singletonList(manifest.getOverrides()), any -> true, config).withStage("hmcl.modpack"));
|
||||
dependents.add(new MinecraftInstanceTask<>(zipFile, modpack.getEncoding(), Collections.singletonList(manifest.getOverrides()), manifest, CurseModpackProvider.INSTANCE, manifest.getName(), manifest.getVersion(), repository.getModpackConfiguration(name)).withStage("hmcl.modpack"));
|
||||
|
||||
dependencies.add(new CurseCompletionTask(dependencyManager, name, manifest));
|
||||
}
|
||||
@@ -125,11 +125,11 @@ public final class CurseInstallTask extends Task<Void> {
|
||||
public void execute() throws Exception {
|
||||
if (config != null) {
|
||||
// For update, remove mods not listed in new manifest
|
||||
for (CurseManifestFile oldCurseManifestFile : config.getManifest().files()) {
|
||||
if (StringUtils.isBlank(oldCurseManifestFile.fileName())) continue;
|
||||
Path oldFile = run.resolve("mods/" + oldCurseManifestFile.fileName());
|
||||
for (CurseManifestFile oldCurseManifestFile : config.getManifest().getFiles()) {
|
||||
if (StringUtils.isBlank(oldCurseManifestFile.getFileName())) continue;
|
||||
Path oldFile = run.resolve("mods/" + oldCurseManifestFile.getFileName());
|
||||
if (Files.notExists(oldFile)) continue;
|
||||
if (manifest.files().stream().noneMatch(oldCurseManifestFile::equals))
|
||||
if (manifest.getFiles().stream().noneMatch(oldCurseManifestFile::equals))
|
||||
Files.deleteIfExists(oldFile);
|
||||
}
|
||||
}
|
||||
|
||||
Loaded 100 of 128 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user