Skip to content

Commit add3824

Browse files
committed
Use Library checkboxes throughout settings
1 parent 75ecba4 commit add3824

3 files changed

Lines changed: 25 additions & 11 deletions

File tree

‎launcher/src/main/java/net/modtale/launcher/ui/common/LauncherUi.java‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,20 @@ public static StackPane miniIcon(String text) {
9292
}
9393

9494
public static Node toggleCard(CheckBox checkBox) {
95-
StackPane card = new StackPane(checkBox);
95+
Label caption = new Label();
96+
caption.textProperty().bind(checkBox.textProperty());
97+
caption.disableProperty().bind(checkBox.disableProperty());
98+
caption.getStyleClass().add("native-check");
99+
caption.setWrapText(true);
100+
caption.setMinWidth(0);
101+
caption.setLabelFor(checkBox);
102+
caption.setOnMouseClicked(event -> {
103+
checkBox.requestFocus();
104+
checkBox.fire();
105+
event.consume();
106+
});
107+
HBox card = new HBox(10, checkBox, caption);
108+
card.setAlignment(javafx.geometry.Pos.CENTER_LEFT);
96109
card.getStyleClass().add("toggle-card");
97110
HBox.setHgrow(card, Priority.ALWAYS);
98111
return card;

‎launcher/src/main/java/net/modtale/launcher/ui/library/LibraryToggleBox.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import javafx.scene.layout.StackPane;
99
import net.modtale.launcher.ui.common.LauncherIcons;
1010

11-
final class LibraryToggleBox extends CheckBox {
12-
LibraryToggleBox() {
11+
public final class LibraryToggleBox extends CheckBox {
12+
public LibraryToggleBox() {
1313
getStyleClass().setAll("library-toggle-box");
1414
setFocusTraversable(true);
1515
setOnMouseClicked(event -> {

‎launcher/src/main/java/net/modtale/launcher/ui/settings/LauncherSettingsForm.java‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import net.modtale.launcher.settings.LauncherConfig;
2121
import net.modtale.launcher.settings.LauncherSettings;
2222
import net.modtale.launcher.ui.common.LauncherView;
23+
import net.modtale.launcher.ui.library.LibraryToggleBox;
2324

2425
public final class LauncherSettingsForm {
2526

@@ -34,10 +35,10 @@ public final class LauncherSettingsForm {
3435
private final ComboBox<HytaleVersion> hytaleVersionCombo = new ComboBox<>();
3536
private final ComboBox<String> launcherChannelCombo = new ComboBox<>();
3637
private final ComboBox<LocaleOption> localeCombo = new ComboBox<>();
37-
private final CheckBox includeDependenciesCheck = new CheckBox();
38-
private final CheckBox includeOptionalCheck = new CheckBox();
39-
private final CheckBox autoUpdatesCheck = new CheckBox();
40-
private final CheckBox launcherAutoUpdatesCheck = new CheckBox();
38+
private final CheckBox includeDependenciesCheck = new LibraryToggleBox();
39+
private final CheckBox includeOptionalCheck = new LibraryToggleBox();
40+
private final CheckBox autoUpdatesCheck = new LibraryToggleBox();
41+
private final CheckBox launcherAutoUpdatesCheck = new LibraryToggleBox();
4142

4243
public LauncherSettingsForm() {
4344
LauncherI18n i18n = LauncherI18n.get();
@@ -63,10 +64,10 @@ public String fromString(String value) {
6364
playHytaleGamePathField, playHytaleUserDataPathField, playHytaleJavaPathField);
6465
launcherChannelCombo.setItems(FXCollections.observableArrayList("stable", "develop"));
6566
styleCombo(localeCombo, hytaleBranchCombo, hytaleVersionCombo, launcherChannelCombo);
66-
includeDependenciesCheck.getStyleClass().add("native-check");
67-
includeOptionalCheck.getStyleClass().add("native-check");
68-
autoUpdatesCheck.getStyleClass().add("native-check");
69-
launcherAutoUpdatesCheck.getStyleClass().add("native-check");
67+
includeDependenciesCheck.accessibleTextProperty().bind(includeDependenciesCheck.textProperty());
68+
includeOptionalCheck.accessibleTextProperty().bind(includeOptionalCheck.textProperty());
69+
autoUpdatesCheck.accessibleTextProperty().bind(autoUpdatesCheck.textProperty());
70+
launcherAutoUpdatesCheck.accessibleTextProperty().bind(launcherAutoUpdatesCheck.textProperty());
7071
}
7172

7273
public TextField modsPathField() {

0 commit comments

Comments
 (0)