diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java b/HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java index 9d75154153..cdfec13673 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java @@ -460,6 +460,21 @@ public void setBackgroundImageOpacity(int backgroundImageOpacity) { this.backgroundImageOpacity.set(backgroundImageOpacity); } + @SerializedName("titleBarText") + private final StringProperty titleBarText = new SimpleStringProperty(""); + + public StringProperty titleBarTextProperty() { + return titleBarText; + } + + public String getTitleBarText() { + return titleBarText.get(); + } + + public void setTitleBarText(String titleBarText) { + this.titleBarText.set(titleBarText); + } + // Networks @SerializedName("autoDownloadThreads") diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java index e5f092c724..565be69a9e 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java @@ -93,6 +93,7 @@ public final class MainPage extends StackPane implements DecoratorPage { private final ObjectProperty latestVersion = new SimpleObjectProperty<>(this, "latestVersion"); private final ObservableList versions = FXCollections.observableArrayList(); private Profile profile; + private Label titleLabel; private TransitionPane announcementPane; private final StackPane updatePane; @@ -104,14 +105,24 @@ public final class MainPage extends StackPane implements DecoratorPage { titleNode.setAlignment(Pos.CENTER_LEFT); ImageView titleIcon = new ImageView(FXUtils.newBuiltinImage("/assets/img/icon-title.png")); - Label titleLabel = new Label(Metadata.FULL_TITLE); + Label versionLabel = new Label(Metadata.VERSION); if (I18n.isUpsideDown()) { titleIcon.setRotate(180); + versionLabel.setRotate(180); titleLabel.setRotate(180); } + versionLabel.getStyleClass().add("jfx-main-version-label"); + + titleLabel = new Label(Metadata.FULL_NAME); titleLabel.getStyleClass().add("jfx-decorator-title"); titleLabel.textFillProperty().bind(Themes.titleFillProperty()); - titleNode.getChildren().setAll(titleIcon, titleLabel); + titleNode.getChildren().setAll(titleIcon, titleLabel, versionLabel); + + config().titleBarTextProperty().addListener((observable, oldValue, newValue) -> { + updateTitle(); + }); + + updateTitle(); state.setValue(new State(null, titleNode, false, false, true)); @@ -274,6 +285,15 @@ public void accept(String currentGame) { } + private void updateTitle() { + String titleText = config().getTitleBarText(); + if (titleText != null && !titleText.trim().isEmpty()) { + titleLabel.setText(titleText.trim()); + } else { + titleLabel.setText(Metadata.FULL_NAME); + } + } + private void showUpdate(boolean show) { doAnimation(show); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/PersonalizationPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/PersonalizationPage.java index 6f19448095..1846d3764e 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/PersonalizationPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/PersonalizationPage.java @@ -110,6 +110,31 @@ public PersonalizationPage() { titleTransparentButton.selectedProperty().bindBidirectional(config().titleTransparentProperty()); titleTransparentButton.setTitle(i18n("settings.launcher.title_transparent")); } + { + BorderPane customizationPane = new BorderPane(); + + VBox leftContent = new VBox(); + Label titleLabel = new Label(i18n("settings.launcher.title_text")); + titleLabel.getStyleClass().add("title-label"); + Label subtitleLabel = new Label(i18n("settings.launcher.title_subtext")); + subtitleLabel.getStyleClass().add("subtitle-label"); + subtitleLabel.setStyle("-fx-font-size: 12px; -fx-text-fill: -monet-on-surface-variant;"); + leftContent.getChildren().addAll(titleLabel, subtitleLabel); + customizationPane.setLeft(leftContent); + + JFXTextField inputField = new JFXTextField(); + inputField.setPrefWidth(150); + inputField.setMaxWidth(150); + inputField.setMinWidth(150); + inputField.setText(config().getTitleBarText()); + inputField.textProperty().addListener((observable, oldValue, newValue) -> { + config().setTitleBarText(newValue); + }); + BorderPane.setAlignment(inputField, Pos.CENTER_RIGHT); + customizationPane.setRight(inputField); + + themeList.getContent().add(customizationPane); + } { LineToggleButton animationButton = new LineToggleButton(); themeList.getContent().add(animationButton); diff --git a/HMCL/src/main/resources/assets/css/root.css b/HMCL/src/main/resources/assets/css/root.css index 54708ea303..5d3f44a069 100644 --- a/HMCL/src/main/resources/assets/css/root.css +++ b/HMCL/src/main/resources/assets/css/root.css @@ -678,6 +678,14 @@ -fx-font-weight: BOLD; } +.jfx-tool-bar .jfx-main-version-label { + -fx-font-weight: BOLD; + -fx-background-color: white; + -fx-text-fill: -monet-primary-container; + -fx-background-radius: 4px; + -fx-padding: 2px 3px; +} + .jfx-tool-bar.background { -fx-background-color: -monet-primary-container; } diff --git a/HMCL/src/main/resources/assets/lang/I18N.properties b/HMCL/src/main/resources/assets/lang/I18N.properties index 6d8f4f9894..4010b36016 100644 --- a/HMCL/src/main/resources/assets/lang/I18N.properties +++ b/HMCL/src/main/resources/assets/lang/I18N.properties @@ -1450,6 +1450,8 @@ settings.launcher.proxy.socks=SOCKS settings.launcher.proxy.username=Username settings.launcher.theme=Theme Color settings.launcher.title_transparent=Transparent Titlebar +settings.launcher.title_text=Custom Title Bar +settings.launcher.title_subtext=Leave empty to use the default settings.launcher.turn_off_animations=Disable Animation settings.launcher.version_list_source=Version List settings.launcher.background.settings.opacity=Opacity diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh.properties b/HMCL/src/main/resources/assets/lang/I18N_zh.properties index a15a7950b3..a7eb8a1692 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh.properties @@ -1235,6 +1235,8 @@ settings.launcher.proxy.socks=SOCKS settings.launcher.proxy.username=帳戶 settings.launcher.theme=主題色 settings.launcher.title_transparent=標題欄透明 +settings.launcher.title_text=自訂標題欄文字 +settings.launcher.title_subtext=若留空則顯示預設標題 settings.launcher.turn_off_animations=關閉動畫 settings.launcher.version_list_source=版本清單來源 settings.launcher.background.settings.opacity=不透明度 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 a5cd75d2c1..da4ef0c63d 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties @@ -1240,6 +1240,8 @@ settings.launcher.proxy.socks=SOCKS settings.launcher.proxy.username=账户 settings.launcher.theme=主题色 settings.launcher.title_transparent=标题栏透明 +settings.launcher.title_text=自定义标题栏 +settings.launcher.title_subtext=为空即为默认 settings.launcher.turn_off_animations=关闭动画 settings.launcher.version_list_source=版本列表源 settings.launcher.background.settings.opacity=不透明度