|
19 | 19 |
|
20 | 20 | import com.jfoenix.controls.*; |
21 | 21 | import com.jfoenix.validation.base.ValidatorBase; |
| 22 | +import javafx.animation.KeyFrame; |
| 23 | +import javafx.animation.KeyValue; |
| 24 | +import javafx.animation.Timeline; |
22 | 25 | import javafx.application.Platform; |
23 | 26 | import javafx.beans.NamedArg; |
24 | 27 | import javafx.beans.binding.BooleanBinding; |
|
36 | 39 | import javafx.scene.control.TextInputControl; |
37 | 40 | import javafx.scene.layout.*; |
38 | 41 |
|
| 42 | +import javafx.util.Duration; |
39 | 43 | import org.jackhuang.hmcl.Metadata; |
40 | 44 | import org.jackhuang.hmcl.auth.AccountFactory; |
41 | 45 | import org.jackhuang.hmcl.auth.CharacterSelector; |
@@ -264,16 +268,33 @@ private void onAccept() { |
264 | 268 | }; |
265 | 269 |
|
266 | 270 | if (factory instanceof OfflineAccountFactory && username != null && !USERNAME_CHECKER_PATTERN.matcher(username).matches()) { |
267 | | - Controllers.confirm( |
| 271 | + JFXButton btnYes = new JFXButton(i18n("button.ok")); |
| 272 | + btnYes.getStyleClass().add("dialog-error"); |
| 273 | + btnYes.setOnAction(e -> doCreate.run()); |
| 274 | + btnYes.setDisable(true); |
| 275 | + |
| 276 | + int countdown = 10; |
| 277 | + KeyFrame[] keyFrames = new KeyFrame[countdown + 1]; |
| 278 | + for (int i = 0; i < countdown; i++) { |
| 279 | + keyFrames[i] = new KeyFrame(Duration.seconds(i), |
| 280 | + new KeyValue(btnYes.textProperty(), i18n("button.ok.countdown", countdown - i))); |
| 281 | + } |
| 282 | + keyFrames[countdown] = new KeyFrame(Duration.seconds(countdown), |
| 283 | + new KeyValue(btnYes.textProperty(), i18n("button.ok")), |
| 284 | + new KeyValue(btnYes.disableProperty(), false)); |
| 285 | + |
| 286 | + Timeline timeline = new Timeline(keyFrames); |
| 287 | + Controllers.confirmAction( |
268 | 288 | i18n("account.methods.offline.name.invalid"), i18n("message.warning"), |
269 | 289 | MessageDialogPane.MessageType.WARNING, |
270 | | - doCreate, |
| 290 | + btnYes, |
271 | 291 | () -> { |
272 | | - lblErrorMessage.setText(i18n("account.methods.offline.name.invalid.tip")); |
| 292 | + timeline.stop(); |
273 | 293 | body.setDisable(false); |
274 | 294 | spinner.hideSpinner(); |
275 | 295 | } |
276 | 296 | ); |
| 297 | + timeline.play(); |
277 | 298 | } else { |
278 | 299 | doCreate.run(); |
279 | 300 | } |
|
0 commit comments