当整合包没有描述时,隐藏查看整合包描述按钮 (#3347)

This commit is contained in:
Glavo
2024-10-15 19:56:32 +08:00
committed by GitHub
parent 936285847c
commit 58e32c4459
3 changed files with 10 additions and 1 deletions

View File

@@ -36,6 +36,7 @@ import org.jackhuang.hmcl.ui.construct.MessageDialogPane;
import org.jackhuang.hmcl.ui.construct.RequiredValidator; import org.jackhuang.hmcl.ui.construct.RequiredValidator;
import org.jackhuang.hmcl.ui.construct.Validator; import org.jackhuang.hmcl.ui.construct.Validator;
import org.jackhuang.hmcl.ui.wizard.WizardController; import org.jackhuang.hmcl.ui.wizard.WizardController;
import org.jackhuang.hmcl.util.StringUtils;
import org.jackhuang.hmcl.util.io.CompressingUtils; import org.jackhuang.hmcl.util.io.CompressingUtils;
import org.jackhuang.hmcl.util.io.FileUtils; import org.jackhuang.hmcl.util.io.FileUtils;
@@ -79,6 +80,8 @@ public final class LocalModpackPage extends ModpackPage {
}); });
} }
btnDescription.setVisible(false);
File selectedFile; File selectedFile;
Optional<File> filePath = tryCast(controller.getSettings().get(MODPACK_FILE), File.class); Optional<File> filePath = tryCast(controller.getSettings().get(MODPACK_FILE), File.class);
if (filePath.isPresent()) { if (filePath.isPresent()) {
@@ -134,6 +137,8 @@ public final class LocalModpackPage extends ModpackPage {
// trim: https://github.com/HMCL-dev/HMCL/issues/962 // trim: https://github.com/HMCL-dev/HMCL/issues/962
txtModpackName.setText(manifest.getName().trim()); txtModpackName.setText(manifest.getName().trim());
} }
btnDescription.setVisible(StringUtils.isNotBlank(manifest.getDescription()));
} }
}).start(); }).start();
} }

View File

@@ -24,6 +24,7 @@ public abstract class ModpackPage extends SpinnerPane implements WizardPage {
protected final Label lblAuthor; protected final Label lblAuthor;
protected final JFXTextField txtModpackName; protected final JFXTextField txtModpackName;
protected final JFXButton btnInstall; protected final JFXButton btnInstall;
protected final JFXButton btnDescription;
protected ModpackPage(WizardController controller) { protected ModpackPage(WizardController controller) {
this.controller = controller; this.controller = controller;
@@ -77,7 +78,7 @@ public abstract class ModpackPage extends SpinnerPane implements WizardPage {
BorderPane descriptionPane = new BorderPane(); BorderPane descriptionPane = new BorderPane();
{ {
JFXButton btnDescription = new JFXButton(i18n("modpack.description")); btnDescription = new JFXButton(i18n("modpack.description"));
btnDescription.getStyleClass().add("jfx-button-border"); btnDescription.getStyleClass().add("jfx-button-border");
btnDescription.setOnAction(e -> onDescribe()); btnDescription.setOnAction(e -> onDescribe());
descriptionPane.setLeft(btnDescription); descriptionPane.setLeft(btnDescription);

View File

@@ -27,6 +27,7 @@ import org.jackhuang.hmcl.ui.construct.MessageDialogPane;
import org.jackhuang.hmcl.ui.construct.RequiredValidator; import org.jackhuang.hmcl.ui.construct.RequiredValidator;
import org.jackhuang.hmcl.ui.construct.Validator; import org.jackhuang.hmcl.ui.construct.Validator;
import org.jackhuang.hmcl.ui.wizard.WizardController; import org.jackhuang.hmcl.ui.wizard.WizardController;
import org.jackhuang.hmcl.util.StringUtils;
import java.io.IOException; import java.io.IOException;
import java.util.Map; import java.util.Map;
@@ -69,6 +70,8 @@ public final class RemoteModpackPage extends ModpackPage {
new Validator(i18n("install.new_game.already_exists"), str -> !profile.getRepository().versionIdConflicts(str)), new Validator(i18n("install.new_game.already_exists"), str -> !profile.getRepository().versionIdConflicts(str)),
new Validator(i18n("install.new_game.malformed"), HMCLGameRepository::isValidVersionId)); new Validator(i18n("install.new_game.malformed"), HMCLGameRepository::isValidVersionId));
} }
btnDescription.setVisible(StringUtils.isNotBlank(manifest.getDescription()));
} }
@Override @Override