Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Select Resource Pack" allow multi-selection #215

Closed
Tiefseetauchner opened this issue Mar 12, 2023 · 3 comments
Closed

"Select Resource Pack" allow multi-selection #215

Tiefseetauchner opened this issue Mar 12, 2023 · 3 comments

Comments

@Tiefseetauchner
Copy link
Contributor

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

@mmdanggg2
Copy link
Collaborator

I was aware of the 8192 limit and it is quite annoying I did think that I could maybe skirt that by using additional preference keys as needed but that seemed like too much work for a fairly rare use case. There's probably not a great reason to not allow adding multiple at once, I did actually implement drag and drop so you can just drop all the files into that box and it will add them all that way.

@Tiefseetauchner
Copy link
Contributor Author

Oh cool! Gonna make a PR as soon as I'm back at my desk then! Thanks for the response! :)

@mmdanggg2
Copy link
Collaborator

Thanks again for these little changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants