Skip to content

"Select Resource Pack" allow multi-selection #215

@Tiefseetauchner

Description

@Tiefseetauchner

I'm using the "Select Resource Pack" dialogue to add mods, I suspect as intended (because it works, really cool actually love that)

Issue is, there's a great many mods in some modpacks. So I was wondering, if the dialogue can be changed to allow multi-select. I'm not used to Java anymore and after wading through the 300 line settings function, I found it, and as far as I can tell it should be fairly trivial to support in this case:

JFileChooser jfc = new JFileChooser(MainWindow.settings.getLastExportPath());
// Only files currently supported, remove when support for directories added
//jfc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
jfc.setMultiSelectionEnabled(true);
jfc.addChoosableFileFilter(new FileFilter() {
	@Override public String getDescription() {return "Extracted pack.mcmeta";}
	@Override public boolean accept(File f) {return f.isDirectory() || f.getName().equals("pack.mcmeta");}
});
jfc.setFileFilter(new FileNameExtensionFilter("Zip & Jar files", "zip", "ZIP", "Zip", "jar", "JAR", "Jar"));
jfc.setCurrentDirectory(Filesystem.getMinecraftDir());
jfc.showDialog(Settings.this, Messages.getString("TexsplitDialog.SEL_RP"));

File[] selectedFiles = jfc.getSelectedFiles();
for (File selectedFile : selectedFiles) {
	if (selectedFile == null) {
		continue;
	}
	listPacks.getModel().add(0, selectedFile);
}

listPacks.setSelectedIndex(0);
saveSettings();
updateResourcePacks(true);

It (kind of) works, except there seems to be a limitation on how many resource packs you can add due to java prefs only allowing 8192 characters in a preference. This limitation is already there, just less likely to be encountered due to how boring it'd be to include that many files one by one

Still think it'd be an improvement, maybe there's a workaround or a inherently better solution. I'd even go as far as suggesting an external tool to extract mod resources, or even extracting them into a local folder, maybe as a seperate feature, but that's a way larger change that I'm not qualified to make I think. Mainly to not contaminate the code base with my restricted Java capabilties

Not making a PR because I wanna gauge interest, if this is a no no feature, I'll just use my own build to do it, if you think it's not bad and have an idea on working around javas pref restrictions, I'll look into that and make a PR

Best, Lena

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions