Skip to content

Commit dfcf889

Browse files
committed
Merge branch 'main' into launch-game
2 parents 097235c + a1e75e4 commit dfcf889

File tree

25 files changed

+231
-117
lines changed

25 files changed

+231
-117
lines changed

HMCL/src/main/java/com/jfoenix/skins/JFXColorPickerSkin.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import javafx.animation.KeyFrame;
2929
import javafx.animation.KeyValue;
3030
import javafx.animation.Timeline;
31+
import javafx.beans.property.ObjectProperty;
32+
import javafx.beans.property.SimpleObjectProperty;
3133
import javafx.css.*;
3234
import javafx.css.converter.BooleanConverter;
3335
import javafx.geometry.Insets;
@@ -60,21 +62,26 @@ public final class JFXColorPickerSkin extends JFXGenericPickerSkin<Color> {
6062
"colorLabelVisible",
6163
true);
6264

65+
private final ObjectProperty<Color> textFill = new SimpleObjectProperty<>(Color.BLACK);
66+
private final ObjectProperty<Background> colorBoxBackground = new SimpleObjectProperty<>(null);
67+
6368
public JFXColorPickerSkin(final ColorPicker colorPicker) {
6469
super(colorPicker);
6570

6671
// create displayNode
6772
displayNode = new Label("");
6873
displayNode.getStyleClass().add("color-label");
6974
displayNode.setMouseTransparent(true);
75+
displayNode.textFillProperty().bind(textFill);
7076

7177
// label graphic
7278
colorBox = new JFXClippedPane(displayNode);
7379
colorBox.getStyleClass().add("color-box");
7480
colorBox.setManaged(false);
81+
colorBox.backgroundProperty().bind(colorBoxBackground);
7582
initColor();
7683
final JFXRippler rippler = new JFXRippler(colorBox, JFXRippler.RipplerMask.FIT);
77-
rippler.ripplerFillProperty().bind(displayNode.textFillProperty());
84+
rippler.ripplerFillProperty().bind(textFill);
7885
getChildren().setAll(rippler);
7986
JFXDepthManager.setDepth(getSkinnable(), 1);
8087
getSkinnable().setPickOnBounds(false);
@@ -168,13 +175,13 @@ private void updateColor() {
168175
200,
169176
Interpolator.EASE_BOTH)));
170177
animateColor.setOnFinished((finish) -> {
171-
JFXNodeUtils.updateBackground(colorBox.getBackground(), colorBox, colorCircle.getFill());
178+
colorBoxBackground.set(new Background(new BackgroundFill(colorCircle.getFill(), new CornerRadii(3), Insets.EMPTY)));
172179
colorBox.getChildren().remove(colorCircle);
173180
});
174181
animateColor.play();
175182
}
176183
// update label color
177-
displayNode.setTextFill(circleColor.grayscale().getRed() < 0.5 ? Color.valueOf(
184+
textFill.set(circleColor.grayscale().getRed() < 0.5 ? Color.valueOf(
178185
"rgba(255, 255, 255, 0.87)") : Color.valueOf("rgba(0, 0, 0, 0.87)"));
179186
if (colorLabelVisible.get()) {
180187
displayNode.setText(JFXNodeUtils.colorToHex(circleColor));
@@ -188,9 +195,9 @@ private void initColor() {
188195
Color color = colorPicker.getValue();
189196
Color circleColor = color == null ? Color.WHITE : color;
190197
// update picker box color
191-
colorBox.setBackground(new Background(new BackgroundFill(circleColor, new CornerRadii(3), Insets.EMPTY)));
198+
colorBoxBackground.set(new Background(new BackgroundFill(circleColor, new CornerRadii(3), Insets.EMPTY)));
192199
// update label color
193-
displayNode.setTextFill(circleColor.grayscale().getRed() < 0.5 ? Color.valueOf(
200+
textFill.set(circleColor.grayscale().getRed() < 0.5 ? Color.valueOf(
194201
"rgba(255, 255, 255, 0.87)") : Color.valueOf("rgba(0, 0, 0, 0.87)"));
195202
if (colorLabelVisible.get()) {
196203
displayNode.setText(JFXNodeUtils.colorToHex(circleColor));

HMCL/src/main/java/com/jfoenix/skins/JFXCustomColorPickerDialog.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@
3232
import javafx.event.EventHandler;
3333
import javafx.geometry.Insets;
3434
import javafx.geometry.Rectangle2D;
35-
import javafx.scene.Node;
3635
import javafx.scene.Scene;
37-
import javafx.scene.control.Label;
3836
import javafx.scene.control.Tab;
3937
import javafx.scene.input.KeyEvent;
4038
import javafx.scene.layout.*;
@@ -156,15 +154,15 @@ public JFXCustomColorPickerDialog(Window owner) {
156154
Color fontColor = ((Color) newVal.getFills().get(0).getFill()).grayscale()
157155
.getRed() > 0.5 ? Color.valueOf(
158156
"rgba(40, 40, 40, 0.87)") : Color.valueOf("rgba(255, 255, 255, 0.87)");
159-
for (Node tabNode : tabs.lookupAll(".tab")) {
160-
for (Node node : tabNode.lookupAll(".tab-label")) {
161-
((Label) node).setTextFill(fontColor);
162-
}
163-
for (Node node : tabNode.lookupAll(".jfx-rippler")) {
164-
((JFXRippler) node).setRipplerFill(fontColor);
165-
}
166-
}
167-
((Pane) tabs.lookup(".tab-selected-line")).setBackground(new Background(new BackgroundFill(fontColor, CornerRadii.EMPTY, Insets.EMPTY)));
157+
// for (Node tabNode : tabs.lookupAll(".tab")) {
158+
// for (Node node : tabNode.lookupAll(".tab-label")) {
159+
// ((Label) node).setTextFill(fontColor);
160+
// }
161+
// for (Node node : tabNode.lookupAll(".jfx-rippler")) {
162+
// ((JFXRippler) node).setRipplerFill(fontColor);
163+
// }
164+
// }
165+
// ((Pane) tabs.lookup(".tab-selected-line")).setBackground(new Background(new BackgroundFill(fontColor, CornerRadii.EMPTY, Insets.EMPTY)));
168166
pickerDecorator.lookupAll(".jfx-decorator-button").forEach(button -> {
169167
((JFXButton) button).setRipplerFill(fontColor);
170168
((SVGGlyph) ((JFXButton) button).getGraphic()).setFill(fontColor);

HMCL/src/main/java/org/jackhuang/hmcl/setting/StyleSheets.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,24 @@
4747
public final class StyleSheets {
4848
private static final int FONT_STYLE_SHEET_INDEX = 0;
4949
private static final int THEME_STYLE_SHEET_INDEX = 1;
50+
private static final int BRIGHTNESS_SHEET_INDEX = 2;
5051

5152
private static final ObservableList<String> stylesheets;
5253

5354
static {
5455
String[] array = new String[]{
5556
getFontStyleSheet(),
5657
getThemeStyleSheet(),
58+
getBrightnessStyleSheet(),
5759
"/assets/css/root.css"
5860
};
5961
stylesheets = FXCollections.observableList(Arrays.asList(array));
6062

6163
FontManager.fontProperty().addListener(o -> stylesheets.set(FONT_STYLE_SHEET_INDEX, getFontStyleSheet()));
62-
Themes.colorSchemeProperty().addListener(o -> stylesheets.set(THEME_STYLE_SHEET_INDEX, getThemeStyleSheet()));
64+
Themes.colorSchemeProperty().addListener(o -> {
65+
stylesheets.set(THEME_STYLE_SHEET_INDEX, getThemeStyleSheet());
66+
stylesheets.set(BRIGHTNESS_SHEET_INDEX, getBrightnessStyleSheet());
67+
});
6368
}
6469

6570
private static String toStyleSheetUri(String styleSheet, String fallback) {
@@ -131,6 +136,12 @@ else if (style.contains("bold"))
131136
return toStyleSheetUri(builder.toString(), defaultCss);
132137
}
133138

139+
private static String getBrightnessStyleSheet() {
140+
return Themes.getColorScheme().getBrightness() == Brightness.LIGHT
141+
? "/assets/css/brightness-light.css"
142+
: "/assets/css/brightness-dark.css";
143+
}
144+
134145
private static void addColor(StringBuilder builder, String name, Color color) {
135146
builder.append(" ").append(name)
136147
.append(": ").append(ThemeColor.getColorDisplayName(color)).append(";\n");
@@ -142,7 +153,7 @@ private static void addColor(StringBuilder builder, String name, Color color, do
142153
}
143154

144155
private static void addColor(StringBuilder builder, ColorScheme scheme, ColorRole role, double opacity) {
145-
builder.append(" ").append(role.getVariableName()).append("-transparent-").append((int) (100 * opacity))
156+
builder.append(" ").append(role.getVariableName()).append("-transparent-%02d".formatted((int) (100 * opacity)))
146157
.append(": ").append(ThemeColor.getColorDisplayNameWithOpacity(scheme.getColor(role), opacity))
147158
.append(";\n");
148159
}
@@ -171,13 +182,6 @@ private static String getThemeStyleSheet() {
171182
addColor(builder, scheme, ColorRole.SURFACE_CONTAINER_LOW, 0.8);
172183
addColor(builder, scheme, ColorRole.SECONDARY_CONTAINER, 0.8);
173184

174-
// If we use -monet-error-container as the tag color, there may be a conflict between the tag and background colors on the mod management page
175-
if (scheme.getBrightness() == Brightness.LIGHT) {
176-
addColor(builder, "-warning-tag-background", Color.web("#f1aeb5"));
177-
} else {
178-
addColor(builder, "-warning-tag-background", Color.web("#2c0b0e"));
179-
}
180-
181185
builder.append("}\n");
182186
return toStyleSheetUri(builder.toString(), blueCss);
183187
}

HMCL/src/main/java/org/jackhuang/hmcl/theme/Themes.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,16 @@ public static ColorScheme getColorScheme() {
113113
return colorScheme.get();
114114
}
115115

116+
private static final ObjectBinding<Color> titleFill = Bindings.createObjectBinding(
117+
() -> config().isTitleTransparent()
118+
? getColorScheme().getOnSurface()
119+
: getColorScheme().getOnPrimaryContainer(),
120+
colorSchemeProperty(),
121+
config().titleTransparentProperty()
122+
);
123+
116124
public static ObservableValue<Color> titleFillProperty() {
117-
return colorSchemeProperty().getOnPrimaryContainer();
125+
return titleFill;
118126
}
119127

120128
public static BooleanBinding darkModeProperty() {

HMCL/src/main/java/org/jackhuang/hmcl/ui/FXUtils.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,6 @@ public static List<Node> parseSegment(String segment, Consumer<String> hyperlink
14681468
hyperlinkAction.accept(link);
14691469
});
14701470
text.setCursor(Cursor.HAND);
1471-
text.setFill(Color.web("#0070E0"));
14721471
text.setUnderline(true);
14731472
texts.add(text);
14741473
} else if ("b".equals(element.getTagName())) {

HMCL/src/main/java/org/jackhuang/hmcl/ui/GameCrashWindow.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ private void exportGameCrashInfo() {
292292
private final class View extends VBox {
293293

294294
View() {
295-
setStyle("-fx-background-color: white");
295+
this.getStyleClass().add("game-crash-window");
296296

297297
HBox titlePane = new HBox();
298298
{
@@ -395,6 +395,7 @@ private final class View extends VBox {
395395
reasonTitle.getStyleClass().add("two-line-item-second-large-title");
396396

397397
ScrollPane reasonPane = new ScrollPane(reasonTextFlow);
398+
reasonTextFlow.getStyleClass().add("crash-reason-text-flow");
398399
reasonPane.setFitToWidth(true);
399400
reasonPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
400401
reasonPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
@@ -411,6 +412,7 @@ private final class View extends VBox {
411412
}
412413

413414
HBox toolBar = new HBox();
415+
VBox.setMargin(toolBar, new Insets(0, 0, 4, 0));
414416
{
415417
JFXButton exportGameCrashInfoButton = FXUtils.newRaisedButton(i18n("logwindow.export_game_crash_logs"));
416418
exportGameCrashInfoButton.setOnAction(e -> exportGameCrashInfo());
@@ -422,7 +424,6 @@ private final class View extends VBox {
422424
helpButton.setOnAction(e -> FXUtils.openLink(Metadata.CONTACT_URL));
423425
FXUtils.installFastTooltip(helpButton, i18n("logwindow.help"));
424426

425-
426427
toolBar.setPadding(new Insets(8));
427428
toolBar.setSpacing(8);
428429
toolBar.getStyleClass().add("jfx-tool-bar");

HMCL/src/main/java/org/jackhuang/hmcl/ui/LogWindow.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ private static final class LogWindowSkin extends SkinBase<LogWindowImpl> {
264264

265265
VBox vbox = new VBox(3);
266266
vbox.setPadding(new Insets(3, 0, 3, 0));
267-
vbox.setStyle("-fx-background-color: white");
268267
getChildren().setAll(vbox);
269268

270269
{
@@ -286,8 +285,7 @@ private static final class LogWindowSkin extends SkinBase<LogWindowImpl> {
286285
HBox hBox = new HBox(3);
287286
for (int i = 0; i < LEVELS.length; i++) {
288287
ToggleButton button = new ToggleButton();
289-
button.setStyle("-fx-background-color: " + FXUtils.toWeb(LEVELS[i].getColor()) + ";");
290-
button.getStyleClass().add("log-toggle");
288+
button.getStyleClass().addAll("log-toggle", LEVELS[i].name().toLowerCase(Locale.ROOT));
291289
button.textProperty().bind(control.buttonText[i]);
292290
button.setSelected(true);
293291
control.showLevel[i].bind(button.selectedProperty());

HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/IconedMenuItem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
public final class IconedMenuItem extends IconedItem {
2525

2626
public IconedMenuItem(SVG icon, String text, Runnable action, JFXPopup popup) {
27-
super(icon != null ? icon.createIcon(14) : null, text);
27+
super(icon != null ? FXUtils.limitingSize(icon.createIcon(14), 14, 14) : null, text);
2828

2929
getStyleClass().setAll("iconed-menu-item");
3030

HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/TaskExecutorDialogPane.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public TaskExecutorDialogPane(@NotNull TaskCancellationAction cancel) {
7676
bottom.setLeft(lblProgress);
7777

7878
btnCancel = new JFXButton(i18n("button.cancel"));
79+
btnCancel.getStyleClass().add("dialog-cancel");
7980
bottom.setRight(btnCancel);
8081
}
8182

HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorSkin.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ private Node createNavBar(Decorator skinnable, double leftPaneWidth, boolean can
304304
BorderPane center = new BorderPane();
305305
if (title != null) {
306306
Label titleLabel = new Label();
307+
titleLabel.textFillProperty().bind(Themes.titleFillProperty());
307308
BorderPane.setAlignment(titleLabel, Pos.CENTER_LEFT);
308309
titleLabel.getStyleClass().add("jfx-decorator-title");
309310
if (titleNode == null) {

0 commit comments

Comments
 (0)