Better theme selection UI
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -108,7 +108,14 @@
|
||||
</VBox>
|
||||
</ComponentList>
|
||||
|
||||
<MultiColorItem fx:id="themeItem" title="%settings.launcher.theme" hasSubtitle="true" />
|
||||
<BorderPane>
|
||||
<left>
|
||||
<Label text="%settings.launcher.theme" BorderPane.alignment="CENTER_LEFT" />
|
||||
</left>
|
||||
<right>
|
||||
<StackPane fx:id="themeColorPickerContainer" minHeight="30" />
|
||||
</right>
|
||||
</BorderPane>
|
||||
|
||||
<VBox spacing="5">
|
||||
<BorderPane><left><Label text="%settings.launcher.log_font" BorderPane.alignment="CENTER_LEFT" /></left><right><HBox spacing="3"><FontComboBox fontSize="12" enableStyle="false" fx:id="cboFont" /><JFXTextField fx:id="txtFontSize" maxWidth="50" minWidth="50" /></HBox></right></BorderPane>
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -89,6 +89,8 @@ color.green=绿色
|
||||
color.orange=橙色
|
||||
color.purple=紫色
|
||||
color.red=红色
|
||||
color.recent=推荐
|
||||
color.custom=自定义颜色
|
||||
|
||||
crash.NoClassDefFound=请确认HMCL本体是否完整
|
||||
crash.advice.ClassNotFoundException=Minecraft不完整或Mod冲突,如果有未能下载的文件请下载成功后重试或是客户端损坏请重试请重新制作客户端或下载整合包解决问题,另可尝试游戏设置->(版本)管理->删除库文件解决问题
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -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
|
||||
|
||||
BIN
lib/JFoenix.jar
BIN
lib/JFoenix.jar
Binary file not shown.
Reference in New Issue
Block a user