mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-02-05 16:44:47 +08:00
使用 ObservableMap 记录已显示的提示 (#2271)
This commit is contained in:
parent
4b2e857f08
commit
6010008409
@ -172,9 +172,6 @@ public final class Config implements Cloneable, Observable {
|
|||||||
@SerializedName("promptedVersion")
|
@SerializedName("promptedVersion")
|
||||||
private StringProperty promptedVersion = new SimpleStringProperty();
|
private StringProperty promptedVersion = new SimpleStringProperty();
|
||||||
|
|
||||||
@SerializedName("hideAnnouncementVersion")
|
|
||||||
private StringProperty hideAnnouncementVersion = new SimpleStringProperty();
|
|
||||||
|
|
||||||
@SerializedName("_version")
|
@SerializedName("_version")
|
||||||
private IntegerProperty configVersion = new SimpleIntegerProperty(0);
|
private IntegerProperty configVersion = new SimpleIntegerProperty(0);
|
||||||
|
|
||||||
@ -197,6 +194,9 @@ public final class Config implements Cloneable, Observable {
|
|||||||
@SerializedName("animationDisabled")
|
@SerializedName("animationDisabled")
|
||||||
private BooleanProperty animationDisabled = new SimpleBooleanProperty();
|
private BooleanProperty animationDisabled = new SimpleBooleanProperty();
|
||||||
|
|
||||||
|
@SerializedName("shownTips")
|
||||||
|
private ObservableMap<String, Object> shownTips = FXCollections.observableHashMap();
|
||||||
|
|
||||||
private transient ObservableHelper helper = new ObservableHelper(this);
|
private transient ObservableHelper helper = new ObservableHelper(this);
|
||||||
|
|
||||||
public Config() {
|
public Config() {
|
||||||
@ -643,15 +643,7 @@ public final class Config implements Cloneable, Observable {
|
|||||||
this.promptedVersion.set(promptedVersion);
|
this.promptedVersion.set(promptedVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getHideAnnouncementVersion() {
|
public ObservableMap<String, Object> getShownTips() {
|
||||||
return hideAnnouncementVersion.get();
|
return shownTips;
|
||||||
}
|
|
||||||
|
|
||||||
public StringProperty hideAnnouncementVersionProperty() {
|
|
||||||
return hideAnnouncementVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHideAnnouncementVersion(String hideAnnouncementDevVersion) {
|
|
||||||
this.hideAnnouncementVersion.set(hideAnnouncementDevVersion);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,8 @@ import static org.jackhuang.hmcl.ui.FXUtils.SINE;
|
|||||||
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
||||||
|
|
||||||
public final class MainPage extends StackPane implements DecoratorPage {
|
public final class MainPage extends StackPane implements DecoratorPage {
|
||||||
|
private static final String ANNOUNCEMENT = "announcement";
|
||||||
|
|
||||||
private final ReadOnlyObjectWrapper<State> state = new ReadOnlyObjectWrapper<>();
|
private final ReadOnlyObjectWrapper<State> state = new ReadOnlyObjectWrapper<>();
|
||||||
|
|
||||||
private final PopupMenu menu = new PopupMenu();
|
private final PopupMenu menu = new PopupMenu();
|
||||||
@ -113,7 +115,7 @@ 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().getHideAnnouncementVersion()))) {
|
if (Metadata.isNightly() || (Metadata.isDev() && !Objects.equals(Metadata.VERSION, config().getShownTips().get(ANNOUNCEMENT)))) {
|
||||||
announcementPane = new VBox(16);
|
announcementPane = new VBox(16);
|
||||||
if (Metadata.isNightly()) {
|
if (Metadata.isNightly()) {
|
||||||
announcementPane.getChildren().add(new AnnouncementCard(i18n("update.channel.nightly.title"), i18n("update.channel.nightly.hint")));
|
announcementPane.getChildren().add(new AnnouncementCard(i18n("update.channel.nightly.title"), i18n("update.channel.nightly.hint")));
|
||||||
@ -297,7 +299,7 @@ public final class MainPage extends StackPane implements DecoratorPage {
|
|||||||
|
|
||||||
public void hideAnnouncementPane() {
|
public void hideAnnouncementPane() {
|
||||||
if (announcementPane != null) {
|
if (announcementPane != null) {
|
||||||
config().setHideAnnouncementVersion(Metadata.VERSION);
|
config().getShownTips().put(ANNOUNCEMENT, Metadata.VERSION);
|
||||||
Pane parent = (Pane) announcementPane.getParent();
|
Pane parent = (Pane) announcementPane.getParent();
|
||||||
if (parent != null)
|
if (parent != null)
|
||||||
parent.getChildren().remove(announcementPane);
|
parent.getChildren().remove(announcementPane);
|
||||||
|
Loading…
Reference in New Issue
Block a user