Skip to content

Commit

Permalink
First work on consent dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Mar 3, 2024
1 parent 84899c6 commit 1727ee8
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 35 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
group 'net.jan'
version '1.8.0-SNAPSHOT'
version '1.8.1-SNAPSHOT'
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public String remoteType() {

@Override
public String offlineName() {
return addonId + ":" + fileId;
return "Project ID: " + addonId + ", File ID: " + fileId;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,20 @@ public void accept(
ModDirectorRemoteMod remoteMod = mod.getRemoteMod();
if(remoteMod != null) {
InstallationPolicy policy = remoteMod.getInstallationPolicy();
if(policy != null) {
String optionalKey = policy.getOptionalKey();
if(optionalKey == null) {
alwaysInstall.add(mod);
} else if(!ignoredGroups.contains(optionalKey)) {
SelectableInstallOption installOption = new SelectableInstallOption(
policy.isSelectedByDefault(),
policy.getName() == null ? remoteMod.offlineName() : policy.getName(),
policy.getDescription()
);
if(optionalKey.equals("$")) {
singleOptions.add(installOption);
} else {
groupOptions.computeIfAbsent(optionalKey, k -> new ArrayList<>()).add(installOption);
}
optionsToMod.put(installOption, mod);
String optionalKey = policy == null ? "$" : policy.getOptionalKey();
if(!ignoredGroups.contains(optionalKey)) {
SelectableInstallOption installOption = new SelectableInstallOption(
policy == null || optionalKey == null || policy.isSelectedByDefault(),
policy == null || policy.getName() == null ? remoteMod.offlineName() : policy.getName() + " - " + remoteMod.offlineName(),
policy == null ? "" : policy.getDescription(),
policy == null || remoteMod.remoteType() == null ? "Unknown" : remoteMod.remoteType()
);
if(optionalKey == null || optionalKey.equals("$")) {
singleOptions.add(installOption);
} else {
groupOptions.computeIfAbsent(optionalKey, k -> new ArrayList<>()).add(installOption);
}
optionsToMod.put(installOption, mod);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
public class SelectableInstallOption {
private final String description;
private final String name;
private final String source;

private boolean selected;

public SelectableInstallOption(boolean selectedByDefault, String name, String description) {
public SelectableInstallOption(boolean selectedByDefault, String name, String description, String source) {
this.selected = selectedByDefault;
this.name = name;
this.description = description;
this.source = source;
}

public boolean isSelected() {
Expand All @@ -27,4 +29,8 @@ public String getName() {
public String getDescription() {
return description;
}

public String getSource() {
return source;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.util.concurrent.CountDownLatch;

public class SetupDialog extends JDialog {
private static final int HEIGHT = 400;
private static final int HEIGHT = 500;
private static final int WIDTH = (int) (HEIGHT * /* golden ratio */ 1.618);

private final ModpackConfiguration configuration;
Expand All @@ -22,7 +22,7 @@ public SetupDialog(ModpackConfiguration configuration) {
this.configuration = configuration;

this.nextButton = new JButton("Next");
this.nextButton.addActionListener((e) -> nextLatch.countDown());
this.nextButton.addActionListener(e -> nextLatch.countDown());

setTitle(configuration.packName());
setSize(WIDTH, HEIGHT);
Expand Down Expand Up @@ -51,17 +51,17 @@ private <T extends JPanel> T updateContent(T newContent, boolean hasNextButton)
scrollPane.setMaximumSize(new Dimension(Integer.MAX_VALUE, HEIGHT - 55));
wrapperPanel.add(scrollPane);

JPanel creditsPanel = new JPanel();
creditsPanel.setMaximumSize(new Dimension(WIDTH, 30));
creditsPanel.setLayout(new BorderLayout());
JPanel consentPanel = new JPanel();
consentPanel.setMaximumSize(new Dimension(WIDTH, 30));
consentPanel.setLayout(new BorderLayout());

wrapperPanel.add(Box.createVerticalStrut(5));

creditsPanel.add(new JLabel("Powered by ModDirector"), BorderLayout.WEST);
wrapperPanel.add(creditsPanel);
consentPanel.add(new JLabel("By checking the boxes above, you give consent to download the respective files!"), BorderLayout.WEST);
wrapperPanel.add(consentPanel);

if(hasNextButton) {
creditsPanel.add(nextButton, BorderLayout.EAST);
consentPanel.add(nextButton, BorderLayout.EAST);
nextButton.setAlignmentX(Component.RIGHT_ALIGNMENT);
nextLatch = new CountDownLatch(1);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class ModSelectionPage extends JPanel {
public ModSelectionPage(InstallSelector selector) {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

JLabel titleLabel = new JLabel("Select mods to install", SwingConstants.CENTER);
JLabel titleLabel = new JLabel("Select files to download", SwingConstants.CENTER);
titleLabel.setFont(new Font(titleLabel.getFont().getName(), Font.BOLD, 20));
titleLabel.setMaximumSize(new Dimension(Integer.MAX_VALUE, titleLabel.getMinimumSize().height));
add(titleLabel);
Expand All @@ -21,20 +21,20 @@ public ModSelectionPage(InstallSelector selector) {
}

private void setupSingleOption(SelectableInstallOption option) {
JPanel optionPanel = new JPanel();
String borderText = option.getSource().startsWith("http") ? "URL" : option.getSource();
JPanel optionPanel = new JPanel(new BorderLayout());
optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS));
optionPanel.setBorder(BorderFactory.createTitledBorder(borderText));

JCheckBox installCheckBox = new JCheckBox("Install");
installCheckBox.setSelected(option.isSelected());
installCheckBox.addItemListener((e) -> option.setSelected(installCheckBox.isSelected()));
String checkboxText = option.getSource().startsWith("http") ? option.getSource() : option.getName();
JCheckBox installCheckBox = new JCheckBox(checkboxText, option.isSelected());
installCheckBox.addItemListener(e -> option.setSelected(installCheckBox.isSelected()));
optionPanel.add(installCheckBox);

if(option.getDescription() != null) {
optionPanel.add(new JLabel(asHtml(option.getDescription())));
}

optionPanel.setBorder(BorderFactory.createTitledBorder(option.getName()));

add(optionPanel);
}

Expand All @@ -50,7 +50,7 @@ private void setupGroupOption(String groupName, List<SelectableInstallOption> op

JRadioButton installRadioButton = new JRadioButton(option.getName());
installRadioButton.setSelected(option.isSelected());
installRadioButton.addItemListener((e) -> option.setSelected(installRadioButton.isSelected()));
installRadioButton.addItemListener(e -> option.setSelected(installRadioButton.isSelected()));
group.add(installRadioButton);
optionPanel.add(installRadioButton);

Expand Down

1 comment on commit 1727ee8

@Lylythii
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consent Update! Woo!

Please sign in to comment.