-
Notifications
You must be signed in to change notification settings - Fork 814
feat+fix:为HMCL启动时添加“Switch Working Directory”并修复文档的一些语法错误 #5260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
deepsleep-v3
wants to merge
11
commits into
HMCL-dev:main
Choose a base branch
from
deepsleep-v3:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Added a confirmation dialog when unexpected folders (resourcepacks, saves, mods, shaderpacks, crash-report) are detected in the version root, prompting the user to switch to 'Isolated' mode. Updated I18N.properties with new dialog strings for this feature.
Replaces manual string concatenation with Path.of() using varargs for directory checks in the ROOT_FOLDER case, improving code readability and reliability.
Added logic to process the user's selection from the working directory switch alert dialog, updating the game directory type or returning the appropriate directory based on the chosen button.
## 问题描述 在后台线程中直接调用JavaFX的Alert组件会导致`IllegalStateException: Not on FX application thread`异常,影响程序稳定性。 ## 修改内容 - 将原有的直接Alert调用包装在`Platform.runLater()`中,确保UI操作在JavaFX应用程序线程执行 - 使用`CompletableFuture`在JavaFX线程和非JavaFX线程之间传递用户选择结果 - 保持原有的业务逻辑和对话框选项不变 - 添加异常处理,在对话框异常时使用默认值继续执行 ## 技术细节 1. 创建`CompletableFuture<ButtonData>`用于接收用户选择 2. 在`Platform.runLater()`中: - 创建Confirmation类型的Alert对话框 - 设置三个按钮选项:是、否、仅本次启动 - 使用`showAndWait()`等待用户响应 - 将用户选择的按钮数据传递给CompletableFuture 3. 在后台线程中使用`future.get()`阻塞等待用户选择 4. 根据按钮数据执行相应的目录设置逻辑 ## 影响范围 - 修复启动器在非JavaFX线程中询问工作目录切换的问题 - 确保线程安全的同时保持原有功能不变 - 提升程序在多线程环境下的稳定性 ## 测试要点 ✅ 在后台线程中调用此代码段能正常显示对话框 ✅ 对话框的三个按钮功能与之前一致 ✅ 异常情况下能使用默认值继续执行 ✅ 不会出现线程阻塞或死锁问题 ## 关联问题 修复了在多线程环境下可能导致的UI崩溃问题
burningtnt
suggested changes
Jan 19, 2026
Member
burningtnt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
粗略的(在没有真正看代码逻辑的情况下)看了一眼,我认为你这里有一堆问题需要改动。
此外,简体中文和繁体中文的翻译是必须的。如果你不能熟练使用繁体中文,可使用机器翻译提供初稿,并注明需要社区成员在 PR 合并前检查润色。
HMCL/src/main/java/org/jackhuang/hmcl/game/HMCLGameLauncher.java
Outdated
Show resolved
Hide resolved
HMCL/src/main/java/org/jackhuang/hmcl/game/HMCLGameRepository.java
Outdated
Show resolved
Hide resolved
HMCL/src/main/java/org/jackhuang/hmcl/game/HMCLGameRepository.java
Outdated
Show resolved
Hide resolved
Wulian233
reviewed
Jan 19, 2026
HMCL/src/main/java/org/jackhuang/hmcl/game/HMCLGameLauncher.java
Outdated
Show resolved
Hide resolved
Author
√ 已解决 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
所以我就把这个弹窗做出来了,由于个人精力原因,暂只翻译了en_US。原理是HMCLGameLauncher生成options.txt的函数(generateOptionsTxt)里getRunDirectory()时先检测repository是否instanceof HMCLGameRepository,再创建变量,再检测:
(代码写的有点烂,请见谅😳)
2. 修复文档的一些语法错误
起因是我在准备提交37a03fc时,发现JavaDoc写了个:
(原句)
限定词(determiner)和物主代词(possessive pronoun)不能一起用!
就顺手修了,修成了:
谁叫我爱MC,爱HMCL呢~