diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/SettingsPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/SettingsPage.java index 2cb99cf2c..3ae536068 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/SettingsPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/SettingsPage.java @@ -18,6 +18,8 @@ package org.jackhuang.hmcl.ui; import com.jfoenix.controls.*; +import com.jfoenix.effects.JFXDepthManager; +import javafx.application.Platform; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; import javafx.collections.FXCollections; @@ -41,7 +43,7 @@ import org.jackhuang.hmcl.util.Lang; import java.net.Proxy; import java.util.Arrays; import java.util.Collections; -import java.util.Set; +import java.util.stream.Collectors; public final class SettingsPage extends StackPane implements DecoratorPage { private final StringProperty title = new SimpleStringProperty(this, "title", Main.i18n("settings.launcher")); @@ -77,7 +79,7 @@ public final class SettingsPage extends StackPane implements DecoratorPage { @FXML private MultiFileItem backgroundItem; @FXML - private MultiColorItem themeItem; + private StackPane themeColorPickerContainer; @FXML private JFXRadioButton chkNoProxy; @FXML @@ -193,38 +195,17 @@ public final class SettingsPage extends StackPane implements DecoratorPage { Settings.INSTANCE.setBackgroundImageType((EnumBackgroundImage) newValue.getUserData())); // theme - themeItem.loadChildren(Arrays.asList( - themeItem.createChildren(Main.i18n("color.blue"), Theme.BLUE), - themeItem.createChildren(Main.i18n("color.dark_blue"), Theme.DARK_BLUE), - themeItem.createChildren(Main.i18n("color.green"), Theme.GREEN), - themeItem.createChildren(Main.i18n("color.orange"), Theme.ORANGE), - themeItem.createChildren(Main.i18n("color.purple"), Theme.PURPLE), - themeItem.createChildren(Main.i18n("color.red"), Theme.RED) - )); - - if (Settings.INSTANCE.getTheme().isCustom()) - themeItem.setColor(Color.web(Settings.INSTANCE.getTheme().getColor())); - - themeItem.setToggleSelectedListener(newValue -> { - if (newValue.getUserData() != null) { - Settings.INSTANCE.setTheme((Theme) newValue.getUserData()); - themeItem.setOnColorPickerChanged(null); - } else { - themeItem.setOnColorPickerChanged(color -> - Settings.INSTANCE.setTheme(Theme.custom(Theme.getColorDisplayName(color)))); - } - }); - - themeItem.getGroup().getToggles().stream().filter(it -> Settings.INSTANCE.getTheme() == it.getUserData() || Settings.INSTANCE.getTheme().isCustom() && themeItem.isCustomToggle(it)).findFirst().ifPresent(it -> it.setSelected(true)); - - Settings.INSTANCE.themeProperty().setChangedListenerAndOperate(it -> { - if (it.isCustom()) - themeItem.setSubtitle(it.getName()); - else - themeItem.setSubtitle(Main.i18n("color." + it.getName().toLowerCase())); - - Controllers.getScene().getStylesheets().setAll(it.getStylesheets()); + JFXColorPicker picker = new JFXColorPicker(Color.web(Settings.INSTANCE.getTheme().getColor()), null); + picker.setCustomColorText(Main.i18n("color.custom")); + picker.setRecentColorsText(Main.i18n("color.recent")); + picker.getCustomColors().setAll(Arrays.stream(Theme.VALUES).map(Theme::getColor).map(Color::web).collect(Collectors.toList())); + picker.setOnAction(e -> { + Theme theme = Theme.custom(Theme.getColorDisplayName(picker.getValue())); + Settings.INSTANCE.setTheme(theme); + Controllers.getScene().getStylesheets().setAll(theme.getStylesheets()); }); + themeColorPickerContainer.getChildren().setAll(picker); + Platform.runLater(() -> JFXDepthManager.setDepth(picker, 0)); } private void initBackgroundItemSubtitle() { diff --git a/HMCL/src/main/resources/assets/fxml/setting.fxml b/HMCL/src/main/resources/assets/fxml/setting.fxml index 51a48c25c..2fd147469 100644 --- a/HMCL/src/main/resources/assets/fxml/setting.fxml +++ b/HMCL/src/main/resources/assets/fxml/setting.fxml @@ -108,7 +108,14 @@ - + + + + + + + diff --git a/HMCL/src/main/resources/assets/lang/I18N.properties b/HMCL/src/main/resources/assets/lang/I18N.properties index 2060c403f..382514688 100644 --- a/HMCL/src/main/resources/assets/lang/I18N.properties +++ b/HMCL/src/main/resources/assets/lang/I18N.properties @@ -89,6 +89,8 @@ color.green=Green color.orange=Orange color.purple=Purple color.red=Red +color.recent=Recommended +color.custom=Custom Color crash.NoClassDefFound=Please check "HMCL" software is complete. crash.advice.ClassNotFoundException=Minecraft or mods are incomplete. Retry if there are some libraries that have not downloaded or update your game and mods! Or you can try Game Settings -> Manage (Version) -> Delete library files to solve the problem. diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties index fcb3a8583..6c5f09b7a 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties @@ -89,6 +89,8 @@ color.green=绿色 color.orange=橙色 color.purple=紫色 color.red=红色 +color.recent=推荐 +color.custom=自定义颜色 crash.NoClassDefFound=请确认HMCL本体是否完整 crash.advice.ClassNotFoundException=Minecraft不完整或Mod冲突,如果有未能下载的文件请下载成功后重试或是客户端损坏请重试请重新制作客户端或下载整合包解决问题,另可尝试游戏设置->(版本)管理->删除库文件解决问题 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 92165eede..568c50bf3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.5.1-bin.zip diff --git a/lib/JFoenix.jar b/lib/JFoenix.jar index 34464f5aa..40a6d972e 100644 Binary files a/lib/JFoenix.jar and b/lib/JFoenix.jar differ