Skip to content

启动时对会丢失游戏数据的情况添加 5 秒确认#5738

Open
CiiLu wants to merge 3 commits intoHMCL-dev:mainfrom
CiiLu:files
Open

启动时对会丢失游戏数据的情况添加 5 秒确认#5738
CiiLu wants to merge 3 commits intoHMCL-dev:mainfrom
CiiLu:files

Conversation

@CiiLu
Copy link
Contributor

@CiiLu CiiLu commented Mar 8, 2026

被 macOS 隔离或者在压缩包中运行(临时目录)都会导致游戏数据在启动器退出后丢失,但观察到用户群很多人看都不看直接点确认回头问自己实例怎么没了

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

该 PR 在启动器检测到“运行目录/配置目录位于临时位置(可能导致退出后数据丢失)”时,引入带倒计时的确认对话框,降低用户误点确认后丢实例/数据的概率。

Changes:

  • 新增 showAlertWithCountdown(...):在对话框中禁用确认按钮并显示倒计时文案,到时后才允许确认。
  • macOS App Translocation 场景改为使用倒计时确认对话框。
  • 配置目录位于临时目录的告警改为使用倒计时确认对话框。

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

&& ConfigHolder.isNewlyCreated()
&& System.getProperty("user.dir").startsWith("/private/var/folders/")) {
if (showAlert(AlertType.WARNING, i18n("fatal.mac_app_translocation"), ButtonType.YES, ButtonType.NO) == ButtonType.NO)
if (showAlertWithCountdown(AlertType.WARNING, i18n("fatal.mac_app_translocation"), 5, ButtonType.YES, ButtonType.NO) == ButtonType.NO)
private static void checkConfigInTempDir() {
if (ConfigHolder.isNewlyCreated() && isConfigInTempDir()
&& showAlert(AlertType.WARNING, i18n("fatal.config_in_temp_dir"), ButtonType.YES, ButtonType.NO) == ButtonType.NO) {
&& showAlertWithCountdown(AlertType.WARNING, i18n("fatal.config_in_temp_dir"), 5, ButtonType.YES, ButtonType.NO) == ButtonType.NO) {
alert.setOnShown(e -> timeline.play());
alert.setOnCloseRequest(e -> timeline.stop());

return alert.showAndWait().orElse(null);
Comment on lines +189 to +200
Button okButton = (Button) alert.getDialogPane().lookupButton(ButtonType.YES);

okButton.setDisable(true);

KeyFrame[] keyFrames = new KeyFrame[seconds + 1];
for (int i = 0; i < seconds; i++) {
keyFrames[i] = new KeyFrame(Duration.seconds(i),
new KeyValue(okButton.textProperty(), i18n("button.ok.countdown", seconds - i)));
}
keyFrames[seconds] = new KeyFrame(Duration.seconds(seconds),
new KeyValue(okButton.textProperty(), i18n("button.ok")),
new KeyValue(okButton.disableProperty(), false));
@Glavo Glavo changed the title 启动时对会丢失游戏数据的情况添加 10 秒确认 启动时对会丢失游戏数据的情况添加 5 秒确认 Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants