@@ -391,9 +391,6 @@ public final class Controllers {
|
|||||||
Controllers.getSettingsPage().showFeedback();
|
Controllers.getSettingsPage().showFeedback();
|
||||||
Controllers.navigate(Controllers.getSettingsPage());
|
Controllers.navigate(Controllers.getSettingsPage());
|
||||||
break;
|
break;
|
||||||
case "hmcl://hide-announcement":
|
|
||||||
Controllers.getRootPage().getMainPage().hideAnnouncementPane();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FXUtils.openLink(href);
|
FXUtils.openLink(href);
|
||||||
|
|||||||
@@ -1005,8 +1005,8 @@ public final class FXUtils {
|
|||||||
hyperlinkAction.accept(link);
|
hyperlinkAction.accept(link);
|
||||||
});
|
});
|
||||||
text.setCursor(Cursor.HAND);
|
text.setCursor(Cursor.HAND);
|
||||||
|
text.setFill(Color.web("#0070E0"));
|
||||||
text.setUnderline(true);
|
text.setUnderline(true);
|
||||||
text.setFill(Color.web("#283593"));
|
|
||||||
texts.add(text);
|
texts.add(text);
|
||||||
} else if ("b".equals(element.getTagName())) {
|
} else if ("b".equals(element.getTagName())) {
|
||||||
Text text = new Text(element.getTextContent());
|
Text text = new Text(element.getTextContent());
|
||||||
|
|||||||
@@ -17,21 +17,36 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hmcl.ui.construct;
|
package org.jackhuang.hmcl.ui.construct;
|
||||||
|
|
||||||
|
import javafx.scene.Cursor;
|
||||||
|
import javafx.scene.Node;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.layout.BorderPane;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.scene.text.TextFlow;
|
import javafx.scene.text.TextFlow;
|
||||||
|
import org.jackhuang.hmcl.setting.Theme;
|
||||||
import org.jackhuang.hmcl.ui.Controllers;
|
import org.jackhuang.hmcl.ui.Controllers;
|
||||||
import org.jackhuang.hmcl.ui.FXUtils;
|
import org.jackhuang.hmcl.ui.FXUtils;
|
||||||
|
import org.jackhuang.hmcl.ui.SVG;
|
||||||
|
|
||||||
public class AnnouncementCard extends VBox {
|
public final class AnnouncementCard extends VBox {
|
||||||
|
|
||||||
public AnnouncementCard(String title, String content) {
|
public AnnouncementCard(String title, String content, Runnable onClose) {
|
||||||
TextFlow tf = FXUtils.segmentToTextFlow(content, Controllers::onHyperlinkAction);
|
TextFlow body = FXUtils.segmentToTextFlow(content, Controllers::onHyperlinkAction);
|
||||||
|
body.setLineSpacing(4);
|
||||||
|
|
||||||
Label label = new Label(title);
|
BorderPane titleBar = new BorderPane();
|
||||||
label.getStyleClass().add("title");
|
titleBar.getStyleClass().add("title");
|
||||||
getChildren().setAll(label, tf);
|
titleBar.setLeft(new Label(title));
|
||||||
setSpacing(14);
|
|
||||||
|
if (onClose != null) {
|
||||||
|
Node hideNode = SVG.CLOSE.createIcon(Theme.blackFill(), 20, 20);
|
||||||
|
hideNode.setOnMouseClicked(e -> onClose.run());
|
||||||
|
hideNode.setCursor(Cursor.HAND);
|
||||||
|
titleBar.setRight(hideNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
getChildren().setAll(titleBar, body);
|
||||||
|
setSpacing(16);
|
||||||
getStyleClass().addAll("card", "announcement");
|
getStyleClass().addAll("card", "announcement");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ import javafx.scene.Node;
|
|||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
import javafx.scene.layout.Pane;
|
|
||||||
import javafx.scene.layout.StackPane;
|
import javafx.scene.layout.StackPane;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.scene.shape.Rectangle;
|
import javafx.scene.shape.Rectangle;
|
||||||
@@ -46,6 +45,8 @@ import org.jackhuang.hmcl.ui.Controllers;
|
|||||||
import org.jackhuang.hmcl.ui.FXUtils;
|
import org.jackhuang.hmcl.ui.FXUtils;
|
||||||
import org.jackhuang.hmcl.ui.SVG;
|
import org.jackhuang.hmcl.ui.SVG;
|
||||||
import org.jackhuang.hmcl.ui.animation.AnimationUtils;
|
import org.jackhuang.hmcl.ui.animation.AnimationUtils;
|
||||||
|
import org.jackhuang.hmcl.ui.animation.ContainerAnimations;
|
||||||
|
import org.jackhuang.hmcl.ui.animation.TransitionPane;
|
||||||
import org.jackhuang.hmcl.ui.construct.AnnouncementCard;
|
import org.jackhuang.hmcl.ui.construct.AnnouncementCard;
|
||||||
import org.jackhuang.hmcl.ui.construct.MessageDialogPane;
|
import org.jackhuang.hmcl.ui.construct.MessageDialogPane;
|
||||||
import org.jackhuang.hmcl.ui.construct.PopupMenu;
|
import org.jackhuang.hmcl.ui.construct.PopupMenu;
|
||||||
@@ -83,7 +84,7 @@ public final class MainPage extends StackPane implements DecoratorPage {
|
|||||||
private final ObservableList<Node> versionNodes;
|
private final ObservableList<Node> versionNodes;
|
||||||
private Profile profile;
|
private Profile profile;
|
||||||
|
|
||||||
private VBox announcementPane;
|
private TransitionPane announcementPane;
|
||||||
private final StackPane updatePane;
|
private final StackPane updatePane;
|
||||||
private final JFXButton menuButton;
|
private final JFXButton menuButton;
|
||||||
|
|
||||||
@@ -102,13 +103,23 @@ public final class MainPage extends StackPane implements DecoratorPage {
|
|||||||
setPadding(new Insets(20));
|
setPadding(new Insets(20));
|
||||||
|
|
||||||
if (Metadata.isNightly() || (Metadata.isDev() && !Objects.equals(Metadata.VERSION, config().getShownTips().get(ANNOUNCEMENT)))) {
|
if (Metadata.isNightly() || (Metadata.isDev() && !Objects.equals(Metadata.VERSION, config().getShownTips().get(ANNOUNCEMENT)))) {
|
||||||
announcementPane = new VBox(16);
|
AnnouncementCard announcementCard = null;
|
||||||
|
|
||||||
if (Metadata.isNightly()) {
|
if (Metadata.isNightly()) {
|
||||||
announcementPane.getChildren().add(new AnnouncementCard(i18n("update.channel.nightly.title"), i18n("update.channel.nightly.hint")));
|
announcementCard = new AnnouncementCard(i18n("update.channel.nightly.title"), i18n("update.channel.nightly.hint"), null);
|
||||||
} else if (Metadata.isDev()) {
|
} else if (Metadata.isDev()) {
|
||||||
announcementPane.getChildren().add(new AnnouncementCard(i18n("update.channel.dev.title"), i18n("update.channel.dev.hint")));
|
announcementCard = new AnnouncementCard(i18n("update.channel.dev.title"), i18n("update.channel.dev.hint"), this::hideAnnouncementPane);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (announcementCard != null) {
|
||||||
|
VBox announcementBox = new VBox(16);
|
||||||
|
announcementBox.getChildren().add(announcementCard);
|
||||||
|
|
||||||
|
announcementPane = new TransitionPane();
|
||||||
|
announcementPane.setContent(announcementBox, ContainerAnimations.NONE.getAnimationProducer());
|
||||||
|
|
||||||
|
getChildren().add(announcementPane);
|
||||||
}
|
}
|
||||||
getChildren().add(announcementPane);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePane = new StackPane();
|
updatePane = new StackPane();
|
||||||
@@ -290,10 +301,7 @@ public final class MainPage extends StackPane implements DecoratorPage {
|
|||||||
public void hideAnnouncementPane() {
|
public void hideAnnouncementPane() {
|
||||||
if (announcementPane != null) {
|
if (announcementPane != null) {
|
||||||
config().getShownTips().put(ANNOUNCEMENT, Metadata.VERSION);
|
config().getShownTips().put(ANNOUNCEMENT, Metadata.VERSION);
|
||||||
Pane parent = (Pane) announcementPane.getParent();
|
announcementPane.setContent(new StackPane(), ContainerAnimations.FADE.getAnimationProducer());
|
||||||
if (parent != null)
|
|
||||||
parent.getChildren().remove(announcementPane);
|
|
||||||
announcementPane = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user