Disable mod pane when Forge/Liteloader is not installed.
This commit is contained in:
@@ -28,6 +28,7 @@ import javafx.scene.control.Control;
|
||||
import javafx.scene.control.Skin;
|
||||
import javafx.scene.control.TreeItem;
|
||||
import javafx.stage.FileChooser;
|
||||
import org.jackhuang.hmcl.download.LibraryAnalyzer;
|
||||
import org.jackhuang.hmcl.mod.ModInfo;
|
||||
import org.jackhuang.hmcl.mod.ModManager;
|
||||
import org.jackhuang.hmcl.setting.Profile;
|
||||
@@ -52,9 +53,11 @@ import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
||||
public final class ModListPage extends Control {
|
||||
private final ListProperty<ModListPageSkin.ModInfoObject> items = new SimpleListProperty<>(this, "items", FXCollections.observableArrayList());
|
||||
private final BooleanProperty loading = new SimpleBooleanProperty(this, "loading", false);
|
||||
private final BooleanProperty modded = new SimpleBooleanProperty(this, "modded", false);
|
||||
|
||||
private JFXTabPane parentTab;
|
||||
private ModManager modManager;
|
||||
private LibraryAnalyzer libraryAnalyzer;
|
||||
|
||||
public ModListPage() {
|
||||
|
||||
@@ -80,10 +83,12 @@ public final class ModListPage extends Control {
|
||||
}
|
||||
|
||||
public void loadVersion(Profile profile, String id) {
|
||||
libraryAnalyzer = LibraryAnalyzer.analyze(profile.getRepository().getResolvedVersion(id));
|
||||
modded.set(libraryAnalyzer.hasForge() || libraryAnalyzer.hasLiteLoader());
|
||||
loadMods(profile.getRepository().getModManager(id));
|
||||
}
|
||||
|
||||
public void loadMods(ModManager modManager) {
|
||||
private void loadMods(ModManager modManager) {
|
||||
this.modManager = modManager;
|
||||
Task.ofResult(() -> {
|
||||
synchronized (ModListPage.this) {
|
||||
@@ -187,4 +192,16 @@ public final class ModListPage extends Control {
|
||||
public BooleanProperty loadingProperty() {
|
||||
return loading;
|
||||
}
|
||||
|
||||
public boolean isModded() {
|
||||
return modded.get();
|
||||
}
|
||||
|
||||
public BooleanProperty moddedProperty() {
|
||||
return modded;
|
||||
}
|
||||
|
||||
public void setModded(boolean modded) {
|
||||
this.modded.set(modded);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,9 +30,11 @@ import javafx.scene.control.*;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.text.TextAlignment;
|
||||
import javafx.util.Callback;
|
||||
import org.jackhuang.hmcl.mod.ModInfo;
|
||||
import org.jackhuang.hmcl.setting.Theme;
|
||||
import org.jackhuang.hmcl.ui.FXUtils;
|
||||
import org.jackhuang.hmcl.ui.SVG;
|
||||
import org.jackhuang.hmcl.ui.construct.JFXCheckBoxTreeTableCell;
|
||||
import org.jackhuang.hmcl.ui.construct.SpinnerPane;
|
||||
@@ -53,6 +55,9 @@ public class ModListPageSkin extends SkinBase<ModListPage> {
|
||||
public ModListPageSkin(ModListPage skinnable) {
|
||||
super(skinnable);
|
||||
|
||||
StackPane pane = new StackPane();
|
||||
pane.getStyleClass().addAll("notice-pane", "white-background");
|
||||
|
||||
BorderPane root = new BorderPane();
|
||||
JFXTreeTableView<ModInfoObject> tableView = new JFXTreeTableView<>();
|
||||
|
||||
@@ -140,7 +145,15 @@ public class ModListPageSkin extends SkinBase<ModListPage> {
|
||||
root.setCenter(center);
|
||||
}
|
||||
|
||||
getChildren().setAll(root);
|
||||
Label label = new Label(i18n("mods.not_modded"));
|
||||
label.prefWidthProperty().bind(pane.widthProperty().add(-100));
|
||||
|
||||
FXUtils.onChangeAndOperate(skinnable.moddedProperty(), modded -> {
|
||||
if (modded) pane.getChildren().setAll(root);
|
||||
else pane.getChildren().setAll(label);
|
||||
});
|
||||
|
||||
getChildren().setAll(pane);
|
||||
}
|
||||
|
||||
private <T> void setupCellValueFactory(JFXTreeTableColumn<ModInfoObject, T> column, Function<ModInfoObject, ObservableValue<T>> mapper) {
|
||||
|
||||
@@ -57,8 +57,11 @@
|
||||
-fx-text-fill: -fx-base-text-fill;
|
||||
}
|
||||
|
||||
.rippler-container= .label {
|
||||
-fx-text-fill: white;
|
||||
.notice-pane > .label {
|
||||
-fx-text-fill: #0079FF;
|
||||
-fx-font-size: 20;
|
||||
-fx-wrap-text: true;
|
||||
-fx-text-alignment: CENTER;
|
||||
}
|
||||
|
||||
.class-title {
|
||||
@@ -1010,7 +1013,7 @@
|
||||
}
|
||||
|
||||
.white-background {
|
||||
-fx-background-color: rgba(255, 255, 255);
|
||||
-fx-background-color: rgb(255, 255, 255);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -1115,7 +1118,7 @@
|
||||
}
|
||||
|
||||
.tree-table-row-group {
|
||||
-fx-background-color: rgba(230, 230, 230);
|
||||
-fx-background-color: rgb(230, 230, 230);
|
||||
}
|
||||
|
||||
.tree-table-view .menu-item:focused {
|
||||
|
||||
@@ -24,11 +24,11 @@
|
||||
<JFXListView fx:id="list" styleClass="jfx-list-view" VBox.vgrow="ALWAYS">
|
||||
</JFXListView>
|
||||
</VBox>
|
||||
<StackPane fx:id="failedPane">
|
||||
<Label onMouseClicked="#onRefresh" style="-fx-text-fill: #0079FF; -fx-font-size: 20;" text="%download.failed.refresh" />
|
||||
<StackPane fx:id="failedPane" styleClass="notice-pane">
|
||||
<Label onMouseClicked="#onRefresh" text="%download.failed.refresh" />
|
||||
</StackPane>
|
||||
<StackPane fx:id="emptyPane">
|
||||
<Label onMouseClicked="#onBack" style="-fx-text-fill: #0079FF; -fx-font-size: 20;" text="%download.failed.empty" />
|
||||
<StackPane fx:id="emptyPane" styleClass="notice-pane">
|
||||
<Label onMouseClicked="#onBack" text="%download.failed.empty" />
|
||||
</StackPane>
|
||||
</StackPane>
|
||||
</center>
|
||||
|
||||
@@ -259,6 +259,7 @@ mods.enable=Enable
|
||||
mods.disable=Disable
|
||||
mods.name=Name
|
||||
mods.remove=Remove
|
||||
mods.not_modded=You should install a mod loader first (Forge, or LiteLoader)
|
||||
|
||||
datapack=Data packs
|
||||
datapack.add=Add data pack
|
||||
|
||||
@@ -257,6 +257,7 @@ mods.choose_mod=選擇模組
|
||||
mods.enable=啟用
|
||||
mods.disable=禁用
|
||||
mods.remove=刪除
|
||||
mods.not_modded=你需要先在自動安裝頁面安裝 Forge 或 LiteLoader 才能進行模組管理。
|
||||
|
||||
datapack=資料包
|
||||
datapack.add=添加資料包
|
||||
|
||||
@@ -257,6 +257,7 @@ mods.choose_mod=选择模组
|
||||
mods.enable=启用
|
||||
mods.disable=禁用
|
||||
mods.remove=删除
|
||||
mods.not_modded=你需要先在自动安装页面安装 Forge 或 LiteLoader 才能进行模组管理。
|
||||
|
||||
datapack=数据包
|
||||
datapack.add=添加数据包
|
||||
|
||||
Reference in New Issue
Block a user