diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/LogWindow.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/LogWindow.java index 4a68ab04b3..2fae01d134 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/LogWindow.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/LogWindow.java @@ -164,6 +164,7 @@ private final class LogWindowImpl extends Control { private final ListView listView = new JFXListView<>(); private final BooleanProperty autoScroll = new SimpleBooleanProperty(); + private final BooleanProperty wrapText = new SimpleBooleanProperty(true); private final StringProperty[] buttonText = new StringProperty[LEVELS.length]; private final BooleanProperty[] showLevel = new BooleanProperty[LEVELS.length]; private final JFXButton btnAlwaysOnTop = FXUtils.newToggleButton4(SVG.KEEP, 20); @@ -174,7 +175,6 @@ private final class LogWindowImpl extends Control { LogWindowImpl() { getStyleClass().add("log-window"); - listView.getStyleClass().add("no-horizontal-scrollbar"); listView.getProperties().put("no-smooth-scrolling", true); listView.setItems(FXCollections.observableList(new CircularArrayList<>(logs.size()))); @@ -331,11 +331,26 @@ private static final class LogWindowSkin extends SkinBase { getStyleClass().add("log-window-list-cell"); Region clippedContainer = (Region) listView.lookup(".clipped-container"); if (clippedContainer != null) { - maxWidthProperty().bind(clippedContainer.widthProperty()); - prefWidthProperty().bind(clippedContainer.widthProperty()); + wrapTextProperty().addListener((obs, oldWrap, nowWrap) -> { + if (nowWrap) { + maxWidthProperty().bind(clippedContainer.widthProperty()); + prefWidthProperty().bind(clippedContainer.widthProperty()); + listView.getStyleClass().add("no-horizontal-scrollbar"); + } else { + maxWidthProperty().unbind(); + prefWidthProperty().unbind(); + + setMaxWidth(Region.USE_PREF_SIZE); + setPrefWidth(Region.USE_COMPUTED_SIZE); + listView.getStyleClass().remove("no-horizontal-scrollbar"); + } + + // only for horizontal scrollbar + listView.requestLayout(); + }); } setPadding(new Insets(2)); - setWrapText(true); + wrapTextProperty().bind(control.wrapText); setGraphic(null); } @@ -395,6 +410,10 @@ protected void updateItem(Log item, boolean empty) { autoScrollCheckBox.setSelected(true); control.autoScroll.bind(autoScrollCheckBox.selectedProperty()); + JFXCheckBox wrapTextCheckBox = new JFXCheckBox(i18n("logwindow.wrap_text")); + wrapTextCheckBox.setSelected(true); + control.wrapText.bind(wrapTextCheckBox.selectedProperty()); + JFXButton exportLogsButton = new JFXButton(i18n("button.export")); exportLogsButton.setOnAction(e -> getSkinnable().onExportLogs()); @@ -414,7 +433,7 @@ protected void updateItem(Log item, boolean empty) { JFXButton clearButton = new JFXButton(i18n("button.clear")); clearButton.setOnAction(e -> getSkinnable().onClear()); - hBox.getChildren().setAll(autoScrollCheckBox, exportLogsButton, terminateButton, exportDumpPane, clearButton); + hBox.getChildren().setAll(autoScrollCheckBox, wrapTextCheckBox, exportLogsButton, terminateButton, exportDumpPane, clearButton); control.getGameProcess().getProcess() .onExit() diff --git a/HMCL/src/main/resources/assets/lang/I18N.properties b/HMCL/src/main/resources/assets/lang/I18N.properties index 8f961f6a4b..368276c462 100644 --- a/HMCL/src/main/resources/assets/lang/I18N.properties +++ b/HMCL/src/main/resources/assets/lang/I18N.properties @@ -948,6 +948,7 @@ logwindow.terminate_game=Kill Game Process logwindow.title=Log logwindow.help=You can navigate to the HMCL community and find others for help. logwindow.autoscroll=Auto-scroll +logwindow.wrap_text=Wrap Text logwindow.export_game_crash_logs=Export Crash Logs logwindow.export_dump=Export Game Stack Dump logwindow.export_dump.no_dependency=Your Java does not contain the dependencies to create the stack dump. Please join our Discord or QQ group for help. diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh.properties b/HMCL/src/main/resources/assets/lang/I18N_zh.properties index 86955f9568..adc271801e 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh.properties @@ -755,6 +755,7 @@ logwindow.terminate_game=結束遊戲處理程式 logwindow.title=日誌 logwindow.help=你可以前往 HMCL 社群,向他人尋求幫助 logwindow.autoscroll=自動滾動 +logwindow.wrap_text=自動換行 logwindow.export_game_crash_logs=匯出遊戲崩潰資訊 logwindow.export_dump=匯出遊戲執行堆疊 logwindow.export_dump.no_dependency=你的 Java 不包含用於建立遊戲執行堆疊的相依元件。請前往 Discord 或 HMCL QQ 群尋求幫助。 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 ad25c12b32..21745ab774 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties @@ -760,6 +760,7 @@ logwindow.terminate_game=结束游戏进程 logwindow.title=日志 logwindow.help=你可以前往 HMCL 社区,寻找他人帮助 logwindow.autoscroll=自动滚动 +logwindow.wrap_text=自动换行 logwindow.export_game_crash_logs=导出游戏崩溃信息 logwindow.export_dump=导出游戏运行栈 logwindow.export_dump.no_dependency=你的 Java 不包含用于创建游戏运行栈的依赖。请前往 HMCL QQ 群或 Discord 寻求帮助。