Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed HMCL/image/april_fools.png
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public Response serve(IHTTPSession session) {
String html;
try {
html = IOUtils.readFullyAsString(OAuthServer.class.getResourceAsStream("/assets/microsoft_auth.html"))
.replace("%style%", Themes.getTheme().toColorScheme().toStyleSheet().replace("-monet", "--monet"))
.replace("%style%", Themes.getColorScheme().toStyleSheet().replace("-monet", "--monet"))
.replace("%lang%", Locale.getDefault().toLanguageTag())
.replace("%success%", i18n("message.success"))
.replace("%ok%", i18n("button.ok"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.glavo.monetfx.Brightness;
import org.glavo.monetfx.ColorRole;
import org.glavo.monetfx.ColorScheme;
import org.jackhuang.hmcl.theme.Theme;
import org.jackhuang.hmcl.theme.ColorTheme;
import org.jackhuang.hmcl.theme.ThemeColor;
import org.jackhuang.hmcl.theme.Themes;
import org.jackhuang.hmcl.ui.FXUtils;
Expand Down Expand Up @@ -161,7 +161,7 @@ private static void addColor(StringBuilder builder, ColorScheme scheme, ColorRol
private static String getThemeStyleSheet() {
final String blueCss = "/assets/css/blue.css";

if (Theme.DEFAULT.equals(Themes.getTheme()))
if (ColorTheme.DEFAULT.equals(Themes.getTheme()))
return blueCss;

ColorScheme scheme = Themes.getColorScheme();
Expand Down
36 changes: 36 additions & 0 deletions HMCL/src/main/java/org/jackhuang/hmcl/theme/ColorTheme.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Hello Minecraft! Launcher
* Copyright (C) 2025 huangyuhui <huanghongxun2008@126.com> and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.jackhuang.hmcl.theme;

import org.glavo.monetfx.*;

/// @author Glavo
public record ColorTheme(ThemeColor primaryColorSeed, Brightness brightness, ColorStyle colorStyle, Contrast contrast) {

public static final ColorTheme DEFAULT = new ColorTheme(ThemeColor.DEFAULT, Brightness.DEFAULT, ColorStyle.FIDELITY, Contrast.DEFAULT);

public ColorScheme toColorScheme() {
return ColorScheme.newBuilder()
.setPrimaryColorSeed(primaryColorSeed.color())
.setColorStyle(colorStyle)
.setBrightness(brightness)
.setSpecVersion(ColorSpecVersion.SPEC_2025)
.setContrast(contrast)
.build();
}
}
94 changes: 0 additions & 94 deletions HMCL/src/main/java/org/jackhuang/hmcl/theme/Theme.java

This file was deleted.

14 changes: 7 additions & 7 deletions HMCL/src/main/java/org/jackhuang/hmcl/theme/Themes.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
/// @author Glavo
public final class Themes {

private static final ObjectExpression<Theme> theme = new ObjectBinding<>() {
private static final ObjectExpression<ColorTheme> theme = new ObjectBinding<>() {
{
List<Observable> observables = new ArrayList<>();

Expand Down Expand Up @@ -89,10 +89,10 @@ private Brightness getBrightness() {
}

@Override
protected Theme computeValue() {
protected ColorTheme computeValue() {
ThemeColor themeColor = Objects.requireNonNullElse(config().getThemeColor(), ThemeColor.DEFAULT);

return new Theme(themeColor, getBrightness(), Theme.DEFAULT.colorStyle(), Contrast.DEFAULT);
return new ColorTheme(themeColor, getBrightness(), ColorTheme.DEFAULT.colorStyle(), Contrast.DEFAULT);
}
};
private static final ColorSchemeProperty colorScheme = new SimpleColorSchemeProperty();
Expand All @@ -102,9 +102,9 @@ protected Theme computeValue() {
);

static {
ChangeListener<Theme> listener = (observable, oldValue, newValue) -> {
ChangeListener<ColorTheme> listener = (observable, oldValue, newValue) -> {
if (!Objects.equals(oldValue, newValue)) {
colorScheme.set(newValue != null ? newValue.toColorScheme() : Theme.DEFAULT.toColorScheme());
colorScheme.set(newValue != null ? newValue.toColorScheme() : ColorTheme.DEFAULT.toColorScheme());
}
};
listener.changed(theme, null, theme.get());
Expand Down Expand Up @@ -171,11 +171,11 @@ private static Brightness getDefaultBrightness() {
return defaultBrightness = brightness;
}

public static ObjectExpression<Theme> themeProperty() {
public static ObjectExpression<ColorTheme> themeProperty() {
return theme;
}

public static Theme getTheme() {
public static ColorTheme getTheme() {
return themeProperty().get();
}

Expand Down
Loading