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