From 64e7cc74b29087fec479bfc16539b23e10eae872 Mon Sep 17 00:00:00 2001 From: huangyuhui Date: Sat, 1 Sep 2018 00:36:18 +0800 Subject: [PATCH] ProfileList --- .../org/jackhuang/hmcl/ui/Controllers.java | 12 ++- .../jackhuang/hmcl/ui/LeftPaneController.java | 57 ++----------- .../hmcl/ui/account/AccountListItemSkin.java | 2 +- .../ui/profile/ProfileAdvancedListItem.java | 60 +++++++++++++ .../hmcl/ui/profile/ProfileList.java | 82 ++++++++++++++++++ .../hmcl/ui/profile/ProfileListItem.java | 83 ++++++++++++++++++ .../hmcl/ui/profile/ProfileListItemSkin.java | 85 +++++++++++++++++++ .../hmcl/ui/profile/ProfileListSkin.java | 77 +++++++++++++++++ .../hmcl/ui/{ => profile}/ProfilePage.java | 4 +- .../hmcl/ui/versions/GameListSkin.java | 14 +-- .../resources/assets/lang/I18N.properties | 4 +- .../resources/assets/lang/I18N_zh.properties | 4 +- .../assets/lang/I18N_zh_CN.properties | 4 +- 13 files changed, 422 insertions(+), 66 deletions(-) create mode 100644 HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileAdvancedListItem.java create mode 100644 HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileList.java create mode 100644 HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileListItem.java create mode 100644 HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileListItemSkin.java create mode 100644 HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileListSkin.java rename HMCL/src/main/java/org/jackhuang/hmcl/ui/{ => profile}/ProfilePage.java (97%) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java index 31533d60a..a4a7314d4 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java @@ -24,8 +24,6 @@ import javafx.scene.layout.Region; import javafx.stage.Stage; import org.jackhuang.hmcl.Launcher; import org.jackhuang.hmcl.Metadata; -import org.jackhuang.hmcl.setting.Profiles; -import org.jackhuang.hmcl.setting.Settings; import org.jackhuang.hmcl.task.Task; import org.jackhuang.hmcl.task.TaskExecutor; import org.jackhuang.hmcl.ui.account.AccountList; @@ -34,6 +32,7 @@ import org.jackhuang.hmcl.ui.construct.InputDialogPane; import org.jackhuang.hmcl.ui.construct.MessageBox; import org.jackhuang.hmcl.ui.construct.MessageDialogPane; import org.jackhuang.hmcl.ui.construct.TaskExecutorDialogPane; +import org.jackhuang.hmcl.ui.profile.ProfileList; import org.jackhuang.hmcl.ui.versions.GameList; import org.jackhuang.hmcl.util.FutureCallback; import org.jackhuang.hmcl.util.JavaVersion; @@ -51,6 +50,7 @@ public final class Controllers { private static VersionPage versionPage = null; private static GameList gameListPage = null; private static AccountList accountListPage = null; + private static ProfileList profileListPage = null; private static AuthlibInjectorServersPage serversPage = null; private static LeftPaneController leftPaneController; private static Decorator decorator; @@ -84,6 +84,13 @@ public final class Controllers { return accountListPage; } + // FXThread + public static ProfileList getProfileListPage() { + if (profileListPage == null) + profileListPage = new ProfileList(); + return profileListPage; + } + // FXThread public static VersionPage getVersionPage() { if (versionPage == null) @@ -202,5 +209,6 @@ public final class Controllers { scene = null; gameListPage = null; accountListPage = null; + profileListPage = null; } } diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/LeftPaneController.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/LeftPaneController.java index e8228c024..cb2eb266c 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/LeftPaneController.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/LeftPaneController.java @@ -18,12 +18,8 @@ package org.jackhuang.hmcl.ui; import com.jfoenix.concurrency.JFXUtilities; -import com.jfoenix.controls.JFXButton; -import javafx.application.Platform; import javafx.beans.binding.When; -import javafx.scene.Node; import javafx.scene.layout.Region; -import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import org.jackhuang.hmcl.event.EventBus; import org.jackhuang.hmcl.event.RefreshedVersionsEvent; @@ -38,30 +34,26 @@ import org.jackhuang.hmcl.task.TaskExecutor; import org.jackhuang.hmcl.ui.account.AccountAdvancedListItem; import org.jackhuang.hmcl.ui.account.AddAccountPane; import org.jackhuang.hmcl.ui.construct.*; +import org.jackhuang.hmcl.ui.profile.ProfileAdvancedListItem; import org.jackhuang.hmcl.ui.versions.GameAdvancedListItem; import org.jackhuang.hmcl.upgrade.UpdateChecker; -import org.jackhuang.hmcl.util.Lang; import java.io.File; -import java.util.LinkedList; -import java.util.Objects; import java.util.concurrent.atomic.AtomicReference; -import static org.jackhuang.hmcl.ui.FXUtils.onInvalidating; import static org.jackhuang.hmcl.util.i18n.I18n.i18n; public final class LeftPaneController { - private final AdvancedListBox leftPane; - private final VBox profilePane = new VBox(); public LeftPaneController(AdvancedListBox leftPane) { - this.leftPane = leftPane; - AccountAdvancedListItem accountListItem = new AccountAdvancedListItem(); accountListItem.setOnAction(e -> Controllers.navigate(Controllers.getAccountListPage())); accountListItem.accountProperty().bind(Accounts.selectedAccountProperty()); - AdvancedListItem2 gameListItem = new GameAdvancedListItem(); + GameAdvancedListItem gameListItem = new GameAdvancedListItem(); gameListItem.setOnAction(e -> Controllers.navigate(Controllers.getGameListPage())); + ProfileAdvancedListItem profileListItem = new ProfileAdvancedListItem(); + profileListItem.setOnAction(e -> Controllers.navigate(Controllers.getProfileListPage())); + profileListItem.profileProperty().bind(Profiles.selectedProfileProperty()); IconedItem launcherSettingsItem = new IconedItem(SVG.gear(Theme.blackFillBinding(), 20, 20)); @@ -83,18 +75,11 @@ public final class LeftPaneController { .add(accountListItem) .startCategory(i18n("version").toUpperCase()) .add(gameListItem) + .startCategory(i18n("profile.title").toUpperCase()) + .add(profileListItem) .startCategory(i18n("launcher").toUpperCase()) - .add(launcherSettingsItem) - .add(new ClassTitle(i18n("profile.title").toUpperCase(), Lang.apply(new JFXButton(), button -> { - button.setGraphic(SVG.plus(Theme.blackFillBinding(), 10, 10)); - button.getStyleClass().add("toggle-icon-tiny"); - button.setOnMouseClicked(e -> - Controllers.getDecorator().showPage(new ProfilePage(null))); - }))) - .add(profilePane); + .add(launcherSettingsItem); - FXUtils.onChangeAndOperate(Profiles.profilesProperty(), a -> onProfilesLoading()); - FXUtils.onChangeAndOperate(Profiles.selectedProfileProperty(), this::onProfileChanged); EventBus.EVENT_BUS.channel(RefreshedVersionsEvent.class).register(event -> onRefreshedVersions((HMCLGameRepository) event.getSource())); if (Profiles.selectedProfileProperty().get().getRepository().isLoaded()) onRefreshedVersions(Profiles.selectedProfileProperty().get().getRepository()); @@ -111,32 +96,6 @@ public final class LeftPaneController { } // ==== - private void onProfileChanged(Profile profile) { - Platform.runLater(() -> { - for (Node node : profilePane.getChildren()) { - if (node instanceof RipplerContainer && node.getProperties().get("profile") instanceof String) { - boolean current = Objects.equals(node.getProperties().get("profile"), profile.getName()); - ((RipplerContainer) node).setSelected(current); - ((AdvancedListItem) ((RipplerContainer) node).getContainer()).setSubtitle(current ? i18n("profile.selected") : ""); - } - } - }); - } - - private void onProfilesLoading() { - LinkedList list = new LinkedList<>(); - for (Profile profile : Profiles.getProfiles()) { - AdvancedListItem item = new AdvancedListItem(Profiles.getProfileDisplayName(profile)); - RipplerContainer ripplerContainer = new RipplerContainer(item); - item.setOnSettingsButtonClicked(e -> Controllers.getDecorator().showPage(new ProfilePage(profile))); - ripplerContainer.setOnMouseClicked(e -> Profiles.setSelectedProfile(profile)); - ripplerContainer.getProperties().put("profile", profile.getName()); - ripplerContainer.maxWidthProperty().bind(leftPane.widthProperty()); - list.add(ripplerContainer); - } - Platform.runLater(() -> profilePane.getChildren().setAll(list)); - } - private boolean checkedModpack = false; private static boolean showNewAccount = true; diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AccountListItemSkin.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AccountListItemSkin.java index 148e16d7a..2b50d2f84 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AccountListItemSkin.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AccountListItemSkin.java @@ -81,7 +81,7 @@ public class AccountListItemSkin extends SkinBase { btnRemove.getStyleClass().add("toggle-icon4"); BorderPane.setAlignment(btnRemove, Pos.CENTER); btnRemove.setGraphic(SVG.delete(Theme.blackFillBinding(), -1, -1)); - JFXUtilities.runInFX(() -> FXUtils.installTooltip(btnRefresh, i18n("button.delete"))); + JFXUtilities.runInFX(() -> FXUtils.installTooltip(btnRemove, i18n("button.delete"))); right.getChildren().add(btnRemove); root.setRight(right); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileAdvancedListItem.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileAdvancedListItem.java new file mode 100644 index 000000000..19d7b1ff9 --- /dev/null +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileAdvancedListItem.java @@ -0,0 +1,60 @@ +/* + * Hello Minecraft! Launcher. + * Copyright (C) 2017 huangyuhui + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see {http://www.gnu.org/licenses/}. + */ +package org.jackhuang.hmcl.ui.profile; + +import javafx.beans.property.ObjectProperty; +import javafx.beans.property.SimpleObjectProperty; +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.StringProperty; +import javafx.geometry.Rectangle2D; +import javafx.scene.image.Image; +import org.jackhuang.hmcl.auth.Account; +import org.jackhuang.hmcl.auth.offline.OfflineAccount; +import org.jackhuang.hmcl.auth.yggdrasil.YggdrasilAccount; +import org.jackhuang.hmcl.game.AccountHelper; +import org.jackhuang.hmcl.setting.Accounts; +import org.jackhuang.hmcl.setting.Profile; +import org.jackhuang.hmcl.setting.Profiles; +import org.jackhuang.hmcl.task.Schedulers; +import org.jackhuang.hmcl.ui.AdvancedListItem2; +import org.jackhuang.hmcl.ui.FXUtils; + +import static org.jackhuang.hmcl.util.i18n.I18n.i18n; + +public class ProfileAdvancedListItem extends AdvancedListItem2 { + private ObjectProperty profile = new SimpleObjectProperty() { + + @Override + protected void invalidated() { + Profile profile = get(); + if (profile == null) { + } else { + titleProperty().set(Profiles.getProfileDisplayName(profile)); + subtitleProperty().set(profile.getGameDir().toString()); + } + } + }; + + public ProfileAdvancedListItem() { + imageProperty().set(new Image("/assets/img/craft_table.png")); + } + + public ObjectProperty profileProperty() { + return profile; + } +} diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileList.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileList.java new file mode 100644 index 000000000..70ca881bb --- /dev/null +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileList.java @@ -0,0 +1,82 @@ +/* + * Hello Minecraft! Launcher. + * Copyright (C) 2017 huangyuhui + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see {http://www.gnu.org/licenses/}. + */ +package org.jackhuang.hmcl.ui.profile; + +import javafx.beans.property.*; +import javafx.collections.FXCollections; +import javafx.scene.control.Control; +import javafx.scene.control.Skin; +import javafx.scene.control.ToggleGroup; +import org.jackhuang.hmcl.setting.Profile; +import org.jackhuang.hmcl.setting.Profiles; +import org.jackhuang.hmcl.ui.Controllers; +import org.jackhuang.hmcl.ui.wizard.DecoratorPage; +import org.jackhuang.hmcl.util.MappedObservableList; + +import static org.jackhuang.hmcl.ui.FXUtils.onInvalidating; +import static org.jackhuang.hmcl.util.i18n.I18n.i18n; + +public class ProfileList extends Control implements DecoratorPage { + private final StringProperty title = new SimpleStringProperty(i18n("profile.manage")); + private final ListProperty items = new SimpleListProperty<>(FXCollections.observableArrayList()); + private ObjectProperty selectedProfile = new SimpleObjectProperty() { + { + items.addListener(onInvalidating(this::invalidated)); + } + + @Override + protected void invalidated() { + Profile selected = get(); + items.forEach(item -> item.selectedProperty().set(item.getProfile() == selected)); + } + }; + + private ToggleGroup toggleGroup; + + public ProfileList() { + toggleGroup = new ToggleGroup(); + + items.bindContent(MappedObservableList.create( + Profiles.profilesProperty(), + profile -> new ProfileListItem(toggleGroup, profile))); + + selectedProfile.bindBidirectional(Profiles.selectedProfileProperty()); + toggleGroup.selectedToggleProperty().addListener((o, a, toggle) -> { + if (toggle == null || toggle.getUserData() == null) return; + selectedProfile.set(((ProfileListItem) toggle.getUserData()).getProfile()); + }); + } + + @Override + protected Skin createDefaultSkin() { + return new ProfileListSkin(this); + } + + public void addNewProfile() { + Controllers.navigate(new ProfilePage(null)); + } + + public ListProperty itemsProperty() { + return items; + } + + @Override + public StringProperty titleProperty() { + return title; + } +} diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileListItem.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileListItem.java new file mode 100644 index 000000000..e49db6441 --- /dev/null +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileListItem.java @@ -0,0 +1,83 @@ +/* + * Hello Minecraft! Launcher. + * Copyright (C) 2017 huangyuhui + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see {http://www.gnu.org/licenses/}. + */ +package org.jackhuang.hmcl.ui.profile; + +import javafx.beans.property.*; +import javafx.geometry.Rectangle2D; +import javafx.scene.control.Control; +import javafx.scene.control.Skin; +import javafx.scene.control.ToggleGroup; +import javafx.scene.image.Image; +import org.jackhuang.hmcl.auth.Account; +import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorAccount; +import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorServer; +import org.jackhuang.hmcl.auth.offline.OfflineAccount; +import org.jackhuang.hmcl.auth.yggdrasil.YggdrasilAccount; +import org.jackhuang.hmcl.game.AccountHelper; +import org.jackhuang.hmcl.setting.Accounts; +import org.jackhuang.hmcl.setting.Profile; +import org.jackhuang.hmcl.setting.Profiles; +import org.jackhuang.hmcl.task.Schedulers; + +import static org.jackhuang.hmcl.util.i18n.I18n.i18n; + +public class ProfileListItem extends Control { + private final Profile profile; + private final ToggleGroup toggleGroup; + private final StringProperty title = new SimpleStringProperty(); + private final StringProperty subtitle = new SimpleStringProperty(); + private final BooleanProperty selected = new SimpleBooleanProperty(); + + public ProfileListItem(ToggleGroup toggleGroup, Profile profile) { + this.profile = profile; + this.toggleGroup = toggleGroup; + + title.set(Profiles.getProfileDisplayName(profile)); + subtitle.set(profile.getGameDir().toString()); + selected.set(Profiles.selectedProfileProperty().get() == profile); + } + + @Override + protected Skin createDefaultSkin() { + return new ProfileListItemSkin(this); + } + + public ToggleGroup getToggleGroup() { + return toggleGroup; + } + + public Profile getProfile() { + return profile; + } + + public StringProperty titleProperty() { + return title; + } + + public StringProperty subtitleProperty() { + return subtitle; + } + + public BooleanProperty selectedProperty() { + return selected; + } + + public void remove() { + Profiles.getProfiles().remove(profile); + } +} diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileListItemSkin.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileListItemSkin.java new file mode 100644 index 000000000..9ec213446 --- /dev/null +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileListItemSkin.java @@ -0,0 +1,85 @@ +/* + * Hello Minecraft! Launcher. + * Copyright (C) 2017 huangyuhui + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see {http://www.gnu.org/licenses/}. + */ +package org.jackhuang.hmcl.ui.profile; + +import com.jfoenix.controls.JFXButton; +import com.jfoenix.controls.JFXRadioButton; +import com.jfoenix.effects.JFXDepthManager; +import javafx.geometry.Pos; +import javafx.scene.control.SkinBase; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.HBox; +import javafx.scene.layout.StackPane; +import org.jackhuang.hmcl.setting.Theme; +import org.jackhuang.hmcl.ui.FXUtils; +import org.jackhuang.hmcl.ui.SVG; +import org.jackhuang.hmcl.ui.TwoLineListItem; + +public class ProfileListItemSkin extends SkinBase { + + public ProfileListItemSkin(ProfileListItem skinnable) { + super(skinnable); + + BorderPane root = new BorderPane(); + + JFXRadioButton chkSelected = new JFXRadioButton(); + BorderPane.setAlignment(chkSelected, Pos.CENTER); + chkSelected.setUserData(skinnable); + chkSelected.selectedProperty().bindBidirectional(skinnable.selectedProperty()); + chkSelected.setToggleGroup(skinnable.getToggleGroup()); + root.setLeft(chkSelected); + + HBox center = new HBox(); + center.setSpacing(8); + center.setAlignment(Pos.CENTER_LEFT); + + StackPane imageViewContainer = new StackPane(); + FXUtils.setLimitWidth(imageViewContainer, 32); + FXUtils.setLimitHeight(imageViewContainer, 32); + + ImageView imageView = new ImageView(); + FXUtils.limitSize(imageView, 32, 32); + imageView.imageProperty().set(new Image("/assets/img/craft_table.png")); + imageViewContainer.getChildren().setAll(imageView); + + TwoLineListItem item = new TwoLineListItem(); + BorderPane.setAlignment(item, Pos.CENTER); + center.getChildren().setAll(imageView, item); + root.setCenter(center); + + HBox right = new HBox(); + right.setAlignment(Pos.CENTER_RIGHT); + + JFXButton btnRemove = new JFXButton(); + btnRemove.setOnMouseClicked(e -> skinnable.remove()); + btnRemove.getStyleClass().add("toggle-icon4"); + BorderPane.setAlignment(btnRemove, Pos.CENTER); + btnRemove.setGraphic(SVG.delete(Theme.blackFillBinding(), -1, -1)); + right.getChildren().add(btnRemove); + root.setRight(right); + + root.setStyle("-fx-background-color: white; -fx-padding: 8 8 8 0;"); + JFXDepthManager.setDepth(root, 1); + item.titleProperty().bind(skinnable.titleProperty()); + item.subtitleProperty().bind(skinnable.subtitleProperty()); + + getChildren().setAll(root); + } +} diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileListSkin.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileListSkin.java new file mode 100644 index 000000000..588fda41f --- /dev/null +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileListSkin.java @@ -0,0 +1,77 @@ +/* + * Hello Minecraft! Launcher. + * Copyright (C) 2017 huangyuhui + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see {http://www.gnu.org/licenses/}. + */ +package org.jackhuang.hmcl.ui.profile; + +import com.jfoenix.controls.JFXButton; +import com.jfoenix.controls.JFXScrollPane; +import javafx.beans.binding.Bindings; +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.scene.control.ScrollPane; +import javafx.scene.control.SkinBase; +import javafx.scene.layout.StackPane; +import javafx.scene.layout.VBox; +import org.jackhuang.hmcl.setting.Theme; +import org.jackhuang.hmcl.ui.FXUtils; +import org.jackhuang.hmcl.ui.SVG; + +public class ProfileListSkin extends SkinBase { + + public ProfileListSkin(ProfileList skinnable) { + super(skinnable); + + StackPane root = new StackPane(); + + ScrollPane scrollPane = new ScrollPane(); + { + scrollPane.setFitToWidth(true); + + VBox accountList = new VBox(); + accountList.maxWidthProperty().bind(scrollPane.widthProperty()); + accountList.setSpacing(10); + accountList.setStyle("-fx-padding: 10 10 10 10;"); + + Bindings.bindContent(accountList.getChildren(), skinnable.itemsProperty()); + + scrollPane.setContent(accountList); + JFXScrollPane.smoothScrolling(scrollPane); + } + + VBox vBox = new VBox(); + { + vBox.setAlignment(Pos.BOTTOM_RIGHT); + vBox.setPickOnBounds(false); + vBox.setPadding(new Insets(15)); + vBox.setSpacing(15); + + JFXButton btnAdd = new JFXButton(); + FXUtils.setLimitWidth(btnAdd, 40); + FXUtils.setLimitHeight(btnAdd, 40); + btnAdd.getStyleClass().setAll("jfx-button-raised-round"); + btnAdd.setButtonType(JFXButton.ButtonType.RAISED); + btnAdd.setGraphic(SVG.plus(Theme.whiteFillBinding(), -1, -1)); + btnAdd.setOnMouseClicked(e -> skinnable.addNewProfile()); + + vBox.getChildren().setAll(btnAdd); + } + + root.getChildren().setAll(scrollPane, vBox); + + getChildren().setAll(root); + } +} diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/ProfilePage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfilePage.java similarity index 97% rename from HMCL/src/main/java/org/jackhuang/hmcl/ui/ProfilePage.java rename to HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfilePage.java index 344a6bd24..cd7961387 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/ProfilePage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfilePage.java @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see {http://www.gnu.org/licenses/}. */ -package org.jackhuang.hmcl.ui; +package org.jackhuang.hmcl.ui.profile; import com.jfoenix.controls.JFXButton; import com.jfoenix.controls.JFXCheckBox; @@ -28,6 +28,8 @@ import javafx.scene.layout.StackPane; import org.jackhuang.hmcl.setting.Profile; import org.jackhuang.hmcl.setting.Profiles; import org.jackhuang.hmcl.setting.Settings; +import org.jackhuang.hmcl.ui.Controllers; +import org.jackhuang.hmcl.ui.FXUtils; import org.jackhuang.hmcl.ui.construct.FileItem; import org.jackhuang.hmcl.ui.wizard.DecoratorPage; import org.jackhuang.hmcl.util.StringUtils; diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameListSkin.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameListSkin.java index b7cf3bb13..da6fbdb73 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameListSkin.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameListSkin.java @@ -79,13 +79,13 @@ public class GameListSkin extends SkinBase { btnRefresh.setOnMouseClicked(e -> skinnable.refresh()); toolbar.getChildren().add(btnRefresh); - JFXButton btnModify = new JFXButton(); - btnModify.getStyleClass().add("jfx-tool-bar-button"); - btnModify.textFillProperty().bind(Theme.foregroundFillBinding()); - btnModify.setGraphic(wrap(SVG.gear(Theme.foregroundFillBinding(), -1, -1))); - btnModify.setText(I18n.i18n("settings.type.global.manage")); - btnModify.setOnMouseClicked(e -> skinnable.modifyGlobalGameSettings()); - toolbar.getChildren().add(btnModify); +// JFXButton btnModify = new JFXButton(); +// btnModify.getStyleClass().add("jfx-tool-bar-button"); +// btnModify.textFillProperty().bind(Theme.foregroundFillBinding()); +// btnModify.setGraphic(wrap(SVG.gear(Theme.foregroundFillBinding(), -1, -1))); +// btnModify.setText(I18n.i18n("settings.type.global.manage")); +// btnModify.setOnMouseClicked(e -> skinnable.modifyGlobalGameSettings()); +// toolbar.getChildren().add(btnModify); root.setTop(toolbar); } diff --git a/HMCL/src/main/resources/assets/lang/I18N.properties b/HMCL/src/main/resources/assets/lang/I18N.properties index afa37c731..eaf4b37a7 100644 --- a/HMCL/src/main/resources/assets/lang/I18N.properties +++ b/HMCL/src/main/resources/assets/lang/I18N.properties @@ -240,12 +240,12 @@ mods.add.success=Successfully added mods %s. mods.choose_mod=Choose your mods mods.remove=Remove - -profile=Profile +profile=Game Directories profile.default=Current directory profile.home=User home profile.instance_directory=Game Directory profile.instance_directory.choose=Choose Game Directory +profile.manage=Game Directory List profile.new=New Config profile.title=Game Directories profile.selected=Selected diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh.properties b/HMCL/src/main/resources/assets/lang/I18N_zh.properties index 36cbcb687..a2145257b 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh.properties @@ -240,12 +240,12 @@ mods.add.success=成功新增模組 %s。 mods.choose_mod=選擇模組 mods.remove=刪除 - -profile=設定 +profile=遊戲目錄 profile.default=目前目錄 profile.home=主資料夾 profile.instance_directory=遊戲路徑 profile.instance_directory.choose=選擇遊戲路徑 +profile.manage=遊戲目錄列表 profile.new=建立設定 profile.title=遊戲目錄 profile.selected=已選取 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 41037eed9..4397f57b3 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties @@ -240,12 +240,12 @@ mods.add.success=成功添加模组 %s。 mods.choose_mod=选择模组 mods.remove=删除 - -profile=配置 +profile=游戏目录 profile.default=当前目录 profile.home=主文件夹 profile.instance_directory=游戏路径 profile.instance_directory.choose=选择游戏路径 +profile.manage=游戏目录列表 profile.new=新建配置 profile.title=游戏目录 profile.selected=已选中