Skip to content
Closed
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
15 changes: 15 additions & 0 deletions HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
24 changes: 22 additions & 2 deletions HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public final class MainPage extends StackPane implements DecoratorPage {
private final ObjectProperty<RemoteVersion> latestVersion = new SimpleObjectProperty<>(this, "latestVersion");
private final ObservableList<Version> versions = FXCollections.observableArrayList();
private Profile profile;
private Label titleLabel;

private TransitionPane announcementPane;
private final StackPane updatePane;
Expand All @@ -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));

Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions HMCL/src/main/resources/assets/css/root.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions HMCL/src/main/resources/assets/lang/I18N.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions HMCL/src/main/resources/assets/lang/I18N_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=不透明度
Expand Down
2 changes: 2 additions & 0 deletions HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=不透明度
Expand Down