Add multiple mods. Closes #287
This commit is contained in:
@@ -140,15 +140,33 @@ public final class ModController {
|
||||
FileChooser chooser = new FileChooser();
|
||||
chooser.setTitle(Main.i18n("mods.choose_mod"));
|
||||
chooser.getExtensionFilters().setAll(new FileChooser.ExtensionFilter(Main.i18n("extension.mod"), "*.jar", "*.zip", "*.litemod"));
|
||||
File res = chooser.showOpenDialog(Controllers.getStage());
|
||||
List<File> res = chooser.showOpenMultipleDialog(Controllers.getStage());
|
||||
|
||||
// It's guaranteed that succeeded and failed are thread safe here.
|
||||
List<String> succeeded = new LinkedList<>();
|
||||
List<String> failed = new LinkedList<>();
|
||||
if (res == null) return;
|
||||
Task.of(() -> modManager.addMod(versionId, res))
|
||||
.finalized(Schedulers.javafx(), (variables, isDependentsSucceeded) -> {
|
||||
if (isDependentsSucceeded)
|
||||
loadMods(modManager, versionId);
|
||||
else
|
||||
Controllers.dialog("mods.failed");
|
||||
}).start();
|
||||
Task.of(variables -> {
|
||||
for (File file : res) {
|
||||
try {
|
||||
modManager.addMod(versionId, file);
|
||||
succeeded.add(file.getName());
|
||||
} catch (Exception e) {
|
||||
Logging.LOG.log(Level.WARNING, "Unable to add mod " + file, e);
|
||||
failed.add(file.getName());
|
||||
|
||||
// Actually addMod will not throw exceptions because FileChooser has already filtered files.
|
||||
}
|
||||
}
|
||||
}).with(Task.of(Schedulers.javafx(), variables -> {
|
||||
List<String> prompt = new LinkedList<>();
|
||||
if (!succeeded.isEmpty())
|
||||
prompt.add(Main.i18n("mods.add.success", String.join(", ", succeeded)));
|
||||
if (!failed.isEmpty())
|
||||
prompt.add(Main.i18n("mods.add.failed", String.join(", ", failed)));
|
||||
Controllers.dialog(String.join("\n", prompt), Main.i18n("mods.add"));
|
||||
loadMods(modManager, versionId);
|
||||
})).start();
|
||||
}
|
||||
|
||||
public void setParentTab(JFXTabPane parentTab) {
|
||||
|
||||
@@ -294,9 +294,10 @@ modpack.wizard.step.initialization.warning=Before making modpack, you should ens
|
||||
|
||||
mods=Mods
|
||||
mods.add=Add
|
||||
mods.add.failed=Failed to add mods %s.
|
||||
mods.add.success=Successfully added mods %s.
|
||||
mods.choose_mod=Choose your mods
|
||||
mods.default_information=Please ensure that you have installed Forge or LiteLoader before installing mods!\nYou can drop your mod files from explorer/finder, and delete mods by the delete button.\nDisable a mod by leaving the check box unchecked; Choose an item to get the information.
|
||||
mods.failed=Unable to add your mod
|
||||
mods.remove=Remove
|
||||
|
||||
operation.confirm_stop=Terminate the operations?
|
||||
|
||||
@@ -293,10 +293,11 @@ modpack.wizard.step.initialization.save=选择要导出到的游戏整合包位
|
||||
modpack.wizard.step.initialization.warning=在制作整合包前,请您确认您选择的版本可以正常启动,\n并保证您的Minecraft是正式版而非快照版,\n而且不应当将不允许非官方途径传播的Mod、材质包等纳入整合包。\n整合包会保存您目前的下载源设置
|
||||
|
||||
mods=模组管理
|
||||
mods.add=添加
|
||||
mods.add=添加模组
|
||||
mods.add.failed=添加模组%s失败。
|
||||
mods.add.success=成功添加模组%s。
|
||||
mods.choose_mod=选择模组
|
||||
mods.default_information=安装Mod前你需要确保已安装Forge或LiteLoader!\n您可以从资源管理器拖动mod文件到列表中来添加mod,同时使用删除键可快速删除选中mod\n点掉mod前面的勾可禁用mod,不会加载;选择mod可以获取mod信息
|
||||
mods.failed=添加失败
|
||||
mods.remove=删除
|
||||
|
||||
operation.confirm_stop=真的要终止操作吗?
|
||||
|
||||
Reference in New Issue
Block a user