mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-17 15:57:18 -04:00
Adjust looking of LeftPaneController
This commit is contained in:
parent
372005dae1
commit
45f55b2075
@ -19,6 +19,7 @@ package org.jackhuang.hmcl.ui;
|
|||||||
|
|
||||||
import com.jfoenix.concurrency.JFXUtilities;
|
import com.jfoenix.concurrency.JFXUtilities;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.layout.Region;
|
import javafx.scene.layout.Region;
|
||||||
import org.jackhuang.hmcl.event.EventBus;
|
import org.jackhuang.hmcl.event.EventBus;
|
||||||
import org.jackhuang.hmcl.event.RefreshedVersionsEvent;
|
import org.jackhuang.hmcl.event.RefreshedVersionsEvent;
|
||||||
@ -36,8 +37,8 @@ import org.jackhuang.hmcl.task.TaskExecutor;
|
|||||||
import org.jackhuang.hmcl.ui.account.AccountAdvancedListItem;
|
import org.jackhuang.hmcl.ui.account.AccountAdvancedListItem;
|
||||||
import org.jackhuang.hmcl.ui.account.AddAccountPane;
|
import org.jackhuang.hmcl.ui.account.AddAccountPane;
|
||||||
import org.jackhuang.hmcl.ui.construct.AdvancedListBox;
|
import org.jackhuang.hmcl.ui.construct.AdvancedListBox;
|
||||||
|
import org.jackhuang.hmcl.ui.construct.AdvancedListItem;
|
||||||
import org.jackhuang.hmcl.ui.construct.DialogCloseEvent;
|
import org.jackhuang.hmcl.ui.construct.DialogCloseEvent;
|
||||||
import org.jackhuang.hmcl.ui.construct.IconedItem;
|
|
||||||
import org.jackhuang.hmcl.ui.profile.ProfileAdvancedListItem;
|
import org.jackhuang.hmcl.ui.profile.ProfileAdvancedListItem;
|
||||||
import org.jackhuang.hmcl.ui.versions.GameAdvancedListItem;
|
import org.jackhuang.hmcl.ui.versions.GameAdvancedListItem;
|
||||||
import org.jackhuang.hmcl.ui.versions.Versions;
|
import org.jackhuang.hmcl.ui.versions.Versions;
|
||||||
@ -61,14 +62,17 @@ public final class LeftPaneController extends AdvancedListBox {
|
|||||||
profileListItem.setOnAction(e -> Controllers.navigate(Controllers.getProfileListPage()));
|
profileListItem.setOnAction(e -> Controllers.navigate(Controllers.getProfileListPage()));
|
||||||
profileListItem.profileProperty().bind(Profiles.selectedProfileProperty());
|
profileListItem.profileProperty().bind(Profiles.selectedProfileProperty());
|
||||||
|
|
||||||
IconedItem gameItem = new IconedItem(FXUtils.limitingSize(SVG.gear(Theme.blackFillBinding(), 20, 20), 32, 20), "iconed-item");
|
AdvancedListItem gameItem = new AdvancedListItem();
|
||||||
gameItem.getLabel().setText(i18n("version.manage"));
|
gameItem.setImage(new Image("/assets/img/bookshelf.png"));
|
||||||
gameItem.setOnMouseClicked(e -> Controllers.navigate(Controllers.getGameListPage()));
|
gameItem.setRightGraphic(SVG.viewList(Theme.blackFillBinding(), -1, -1));
|
||||||
|
gameItem.setTitle(i18n("version.manage"));
|
||||||
|
gameItem.setOnAction(e -> Controllers.navigate(Controllers.getGameListPage()));
|
||||||
|
|
||||||
IconedItem launcherSettingsItem = new IconedItem(FXUtils.limitingSize(SVG.gear(Theme.blackFillBinding(), 20, 20), 32, 20), "iconed-item");
|
AdvancedListItem launcherSettingsItem = new AdvancedListItem();
|
||||||
launcherSettingsItem.getLabel().setText(i18n("settings.launcher"));
|
launcherSettingsItem.setImage(new Image("/assets/img/command.png"));
|
||||||
|
launcherSettingsItem.setRightGraphic(SVG.gear(Theme.blackFillBinding(), -1, -1));
|
||||||
launcherSettingsItem.setOnMouseClicked(e -> Controllers.navigate(Controllers.getSettingsPage()));
|
launcherSettingsItem.setTitle(i18n("settings.launcher"));
|
||||||
|
launcherSettingsItem.setOnAction(e -> Controllers.navigate(Controllers.getSettingsPage()));
|
||||||
|
|
||||||
this
|
this
|
||||||
.startCategory(i18n("account").toUpperCase())
|
.startCategory(i18n("account").toUpperCase())
|
||||||
|
@ -158,4 +158,8 @@ public final class SVG {
|
|||||||
public static Node home(ObjectBinding<? extends Paint> fill, double width, double height) {
|
public static Node home(ObjectBinding<? extends Paint> fill, double width, double height) {
|
||||||
return createSVGPath("M10,20V14H14V20H19V12H22L12,3L2,12H5V20H10Z", fill, width, height);
|
return createSVGPath("M10,20V14H14V20H19V12H22L12,3L2,12H5V20H10Z", fill, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Node viewList(ObjectBinding<? extends Paint> fill, double width, double height) {
|
||||||
|
return createSVGPath("M7,5H21V7H7V5M7,13V11H21V13H7M4,4.5A1.5,1.5 0 0,1 5.5,6A1.5,1.5 0 0,1 4,7.5A1.5,1.5 0 0,1 2.5,6A1.5,1.5 0 0,1 4,4.5M4,10.5A1.5,1.5 0 0,1 5.5,12A1.5,1.5 0 0,1 4,13.5A1.5,1.5 0 0,1 2.5,12A1.5,1.5 0 0,1 4,10.5M7,19V17H21V19H7M4,16.5A1.5,1.5 0 0,1 5.5,18A1.5,1.5 0 0,1 4,19.5A1.5,1.5 0 0,1 2.5,18A1.5,1.5 0 0,1 4,16.5Z", fill, width, height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,9 @@ import org.jackhuang.hmcl.auth.Account;
|
|||||||
import org.jackhuang.hmcl.auth.offline.OfflineAccount;
|
import org.jackhuang.hmcl.auth.offline.OfflineAccount;
|
||||||
import org.jackhuang.hmcl.auth.yggdrasil.YggdrasilAccount;
|
import org.jackhuang.hmcl.auth.yggdrasil.YggdrasilAccount;
|
||||||
import org.jackhuang.hmcl.game.AccountHelper;
|
import org.jackhuang.hmcl.game.AccountHelper;
|
||||||
|
import org.jackhuang.hmcl.setting.Theme;
|
||||||
import org.jackhuang.hmcl.task.Schedulers;
|
import org.jackhuang.hmcl.task.Schedulers;
|
||||||
|
import org.jackhuang.hmcl.ui.SVG;
|
||||||
import org.jackhuang.hmcl.ui.construct.AdvancedListItem;
|
import org.jackhuang.hmcl.ui.construct.AdvancedListItem;
|
||||||
|
|
||||||
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
||||||
@ -36,21 +38,21 @@ public class AccountAdvancedListItem extends AdvancedListItem {
|
|||||||
protected void invalidated() {
|
protected void invalidated() {
|
||||||
Account account = get();
|
Account account = get();
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
titleProperty().set(i18n("account.missing"));
|
setTitle(i18n("account.missing"));
|
||||||
subtitleProperty().set(i18n("account.missing.add"));
|
setSubtitle(i18n("account.missing.add"));
|
||||||
imageProperty().set(new Image("/assets/img/craft_table.png"));
|
setImage(new Image("/assets/img/craft_table.png"));
|
||||||
} else {
|
} else {
|
||||||
titleProperty().set(account.getCharacter());
|
setTitle(account.getCharacter());
|
||||||
subtitleProperty().set(accountSubtitle(account));
|
setSubtitle(accountSubtitle(account));
|
||||||
|
|
||||||
final int scaleRatio = 4;
|
final int scaleRatio = 4;
|
||||||
Image defaultSkin = AccountHelper.getDefaultSkin(account.getUUID(), scaleRatio);
|
Image defaultSkin = AccountHelper.getDefaultSkin(account.getUUID(), scaleRatio);
|
||||||
imageProperty().set(AccountHelper.getHead(defaultSkin, scaleRatio));
|
setImage(AccountHelper.getHead(defaultSkin, scaleRatio));
|
||||||
|
|
||||||
if (account instanceof YggdrasilAccount) {
|
if (account instanceof YggdrasilAccount) {
|
||||||
AccountHelper.loadSkinAsync((YggdrasilAccount) account).subscribe(Schedulers.javafx(), () -> {
|
AccountHelper.loadSkinAsync((YggdrasilAccount) account).subscribe(Schedulers.javafx(), () -> {
|
||||||
Image image = AccountHelper.getSkin((YggdrasilAccount) account, scaleRatio);
|
Image image = AccountHelper.getSkin((YggdrasilAccount) account, scaleRatio);
|
||||||
imageProperty().set(AccountHelper.getHead(image, scaleRatio));
|
setImage(AccountHelper.getHead(image, scaleRatio));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -58,6 +60,7 @@ public class AccountAdvancedListItem extends AdvancedListItem {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public AccountAdvancedListItem() {
|
public AccountAdvancedListItem() {
|
||||||
|
setRightGraphic(SVG.viewList(Theme.blackFillBinding(), -1, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObjectProperty<Account> accountProperty() {
|
public ObjectProperty<Account> accountProperty() {
|
||||||
|
@ -20,33 +20,83 @@ package org.jackhuang.hmcl.ui.construct;
|
|||||||
import javafx.beans.property.*;
|
import javafx.beans.property.*;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
import javafx.geometry.Rectangle2D;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.control.Control;
|
import javafx.scene.control.Control;
|
||||||
import javafx.scene.control.Skin;
|
import javafx.scene.control.Skin;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
|
import javafx.scene.input.MouseEvent;
|
||||||
|
|
||||||
public class AdvancedListItem extends Control {
|
public class AdvancedListItem extends Control {
|
||||||
private final ObjectProperty<Image> image = new SimpleObjectProperty<>(this, "image");
|
private final ObjectProperty<Image> image = new SimpleObjectProperty<>(this, "image");
|
||||||
|
private final ObjectProperty<Node> rightGraphic = new SimpleObjectProperty<>(this, "rightGraphic");
|
||||||
private final StringProperty title = new SimpleStringProperty(this, "title");
|
private final StringProperty title = new SimpleStringProperty(this, "title");
|
||||||
private final StringProperty subtitle = new SimpleStringProperty(this, "subtitle");
|
private final StringProperty subtitle = new SimpleStringProperty(this, "subtitle");
|
||||||
private final BooleanProperty actionButtonVisible = new SimpleBooleanProperty(this, "actionButtonVisible", true);
|
private final BooleanProperty actionButtonVisible = new SimpleBooleanProperty(this, "actionButtonVisible", true);
|
||||||
|
|
||||||
|
public AdvancedListItem() {
|
||||||
|
addEventHandler(MouseEvent.MOUSE_CLICKED, e -> fireEvent(new ActionEvent()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image getImage() {
|
||||||
|
return image.get();
|
||||||
|
}
|
||||||
|
|
||||||
public ObjectProperty<Image> imageProperty() {
|
public ObjectProperty<Image> imageProperty() {
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setImage(Image image) {
|
||||||
|
this.image.set(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Node getRightGraphic() {
|
||||||
|
return rightGraphic.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObjectProperty<Node> rightGraphicProperty() {
|
||||||
|
return rightGraphic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRightGraphic(Node rightGraphic) {
|
||||||
|
this.rightGraphic.set(rightGraphic);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title.get();
|
||||||
|
}
|
||||||
|
|
||||||
public StringProperty titleProperty() {
|
public StringProperty titleProperty() {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title.set(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSubtitle() {
|
||||||
|
return subtitle.get();
|
||||||
|
}
|
||||||
|
|
||||||
public StringProperty subtitleProperty() {
|
public StringProperty subtitleProperty() {
|
||||||
return subtitle;
|
return subtitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSubtitle(String subtitle) {
|
||||||
|
this.subtitle.set(subtitle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isActionButtonVisible() {
|
||||||
|
return actionButtonVisible.get();
|
||||||
|
}
|
||||||
|
|
||||||
public BooleanProperty actionButtonVisibleProperty() {
|
public BooleanProperty actionButtonVisibleProperty() {
|
||||||
return actionButtonVisible;
|
return actionButtonVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setActionButtonVisible(boolean actionButtonVisible) {
|
||||||
|
this.actionButtonVisible.set(actionButtonVisible);
|
||||||
|
}
|
||||||
|
|
||||||
public final ObjectProperty<EventHandler<ActionEvent>> onActionProperty() {
|
public final ObjectProperty<EventHandler<ActionEvent>> onActionProperty() {
|
||||||
return onAction;
|
return onAction;
|
||||||
}
|
}
|
||||||
|
@ -28,9 +28,7 @@ import javafx.scene.layout.HBox;
|
|||||||
import javafx.scene.layout.StackPane;
|
import javafx.scene.layout.StackPane;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.scene.text.TextAlignment;
|
import javafx.scene.text.TextAlignment;
|
||||||
import org.jackhuang.hmcl.setting.Theme;
|
|
||||||
import org.jackhuang.hmcl.ui.FXUtils;
|
import org.jackhuang.hmcl.ui.FXUtils;
|
||||||
import org.jackhuang.hmcl.ui.SVG;
|
|
||||||
|
|
||||||
public class AdvancedListItemSkin extends SkinBase<AdvancedListItem> {
|
public class AdvancedListItemSkin extends SkinBase<AdvancedListItem> {
|
||||||
|
|
||||||
@ -38,6 +36,7 @@ public class AdvancedListItemSkin extends SkinBase<AdvancedListItem> {
|
|||||||
super(skinnable);
|
super(skinnable);
|
||||||
|
|
||||||
StackPane stackPane = new StackPane();
|
StackPane stackPane = new StackPane();
|
||||||
|
RipplerContainer container = new RipplerContainer(stackPane);
|
||||||
|
|
||||||
BorderPane root = new BorderPane();
|
BorderPane root = new BorderPane();
|
||||||
root.setPickOnBounds(false);
|
root.setPickOnBounds(false);
|
||||||
@ -89,7 +88,7 @@ public class AdvancedListItemSkin extends SkinBase<AdvancedListItem> {
|
|||||||
JFXButton settings = new JFXButton();
|
JFXButton settings = new JFXButton();
|
||||||
FXUtils.setLimitWidth(settings, 40);
|
FXUtils.setLimitWidth(settings, 40);
|
||||||
settings.getStyleClass().setAll("toggle-icon4");
|
settings.getStyleClass().setAll("toggle-icon4");
|
||||||
settings.setGraphic(SVG.gear(Theme.blackFillBinding(), -1, -1));
|
settings.graphicProperty().bind(skinnable.rightGraphicProperty());
|
||||||
right.getChildren().setAll(settings);
|
right.getChildren().setAll(settings);
|
||||||
root.setRight(right);
|
root.setRight(right);
|
||||||
|
|
||||||
@ -103,6 +102,6 @@ public class AdvancedListItemSkin extends SkinBase<AdvancedListItem> {
|
|||||||
stackPane.setPickOnBounds(false);
|
stackPane.setPickOnBounds(false);
|
||||||
stackPane.getChildren().setAll(root);
|
stackPane.getChildren().setAll(root);
|
||||||
|
|
||||||
getChildren().setAll(stackPane);
|
getChildren().setAll(container);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,8 @@ import javafx.beans.property.SimpleObjectProperty;
|
|||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import org.jackhuang.hmcl.setting.Profile;
|
import org.jackhuang.hmcl.setting.Profile;
|
||||||
import org.jackhuang.hmcl.setting.Profiles;
|
import org.jackhuang.hmcl.setting.Profiles;
|
||||||
|
import org.jackhuang.hmcl.setting.Theme;
|
||||||
|
import org.jackhuang.hmcl.ui.SVG;
|
||||||
import org.jackhuang.hmcl.ui.construct.AdvancedListItem;
|
import org.jackhuang.hmcl.ui.construct.AdvancedListItem;
|
||||||
|
|
||||||
public class ProfileAdvancedListItem extends AdvancedListItem {
|
public class ProfileAdvancedListItem extends AdvancedListItem {
|
||||||
@ -32,14 +34,15 @@ public class ProfileAdvancedListItem extends AdvancedListItem {
|
|||||||
Profile profile = get();
|
Profile profile = get();
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
} else {
|
} else {
|
||||||
titleProperty().set(Profiles.getProfileDisplayName(profile));
|
setTitle(Profiles.getProfileDisplayName(profile));
|
||||||
subtitleProperty().set(profile.getGameDir().toString());
|
setSubtitle(profile.getGameDir().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public ProfileAdvancedListItem() {
|
public ProfileAdvancedListItem() {
|
||||||
imageProperty().set(new Image("/assets/img/craft_table.png"));
|
setImage(new Image("/assets/img/craft_table.png"));
|
||||||
|
setRightGraphic(SVG.viewList(Theme.blackFillBinding(), -1, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObjectProperty<Profile> profileProperty() {
|
public ObjectProperty<Profile> profileProperty() {
|
||||||
|
@ -24,7 +24,9 @@ import org.jackhuang.hmcl.event.EventBus;
|
|||||||
import org.jackhuang.hmcl.event.RefreshedVersionsEvent;
|
import org.jackhuang.hmcl.event.RefreshedVersionsEvent;
|
||||||
import org.jackhuang.hmcl.setting.Profile;
|
import org.jackhuang.hmcl.setting.Profile;
|
||||||
import org.jackhuang.hmcl.setting.Profiles;
|
import org.jackhuang.hmcl.setting.Profiles;
|
||||||
|
import org.jackhuang.hmcl.setting.Theme;
|
||||||
import org.jackhuang.hmcl.ui.FXUtils;
|
import org.jackhuang.hmcl.ui.FXUtils;
|
||||||
|
import org.jackhuang.hmcl.ui.SVG;
|
||||||
import org.jackhuang.hmcl.ui.WeakListenerHolder;
|
import org.jackhuang.hmcl.ui.WeakListenerHolder;
|
||||||
import org.jackhuang.hmcl.ui.construct.AdvancedListItem;
|
import org.jackhuang.hmcl.ui.construct.AdvancedListItem;
|
||||||
|
|
||||||
@ -41,13 +43,15 @@ public class GameAdvancedListItem extends AdvancedListItem {
|
|||||||
imageProperty().set(Profiles.getSelectedProfile().getRepository().getVersionIconImage(version));
|
imageProperty().set(Profiles.getSelectedProfile().getRepository().getVersionIconImage(version));
|
||||||
|
|
||||||
if (version != null) {
|
if (version != null) {
|
||||||
titleProperty().set(version);
|
setTitle(version);
|
||||||
subtitleProperty().set(null);
|
setSubtitle(null);
|
||||||
} else {
|
} else {
|
||||||
titleProperty().set(i18n("version.empty"));
|
setTitle(i18n("version.empty"));
|
||||||
subtitleProperty().set(i18n("version.empty.add"));
|
setSubtitle(i18n("version.empty.add"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setRightGraphic(SVG.gear(Theme.blackFillBinding(), -1, -1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BIN
HMCL/src/main/resources/assets/img/bookshelf.png
Normal file
BIN
HMCL/src/main/resources/assets/img/bookshelf.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.4 KiB |
Loading…
x
Reference in New Issue
Block a user