mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-22 10:43:57 -04:00
Merge 846bfe1f32fa85a33c255bbce443e18c75adb40a into bd9ae189f83e33a6977bbe056774c851e96fe0a7
This commit is contained in:
commit
ab3985ab63
@ -33,12 +33,13 @@ import static javafx.beans.binding.Bindings.createBooleanBinding;
|
||||
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
||||
|
||||
public class InstallersPage extends AbstractInstallersPage {
|
||||
private final HMCLGameRepository repository;
|
||||
|
||||
private boolean isNameModifiedByUser = false;
|
||||
|
||||
public InstallersPage(WizardController controller, HMCLGameRepository repository, String gameVersion, DownloadProvider downloadProvider) {
|
||||
super(controller, gameVersion, downloadProvider);
|
||||
|
||||
this.repository = repository;
|
||||
txtName.getValidators().addAll(
|
||||
new RequiredValidator(),
|
||||
new Validator(i18n("install.new_game.already_exists"), str -> !repository.versionIdConflicts(str)),
|
||||
@ -100,6 +101,7 @@ public class InstallersPage extends AbstractInstallersPage {
|
||||
.yesOrNo(() -> {
|
||||
controller.getSettings().put("name", name);
|
||||
controller.onFinish();
|
||||
createRequiredFolders(name);
|
||||
}, () -> {
|
||||
// The user selects Cancel and does nothing.
|
||||
})
|
||||
@ -107,6 +109,30 @@ public class InstallersPage extends AbstractInstallersPage {
|
||||
} else {
|
||||
controller.getSettings().put("name", name);
|
||||
controller.onFinish();
|
||||
createRequiredFolders(name);
|
||||
}
|
||||
}
|
||||
|
||||
private void createRequiredFolders(String versionName) {
|
||||
for (InstallerItem library : group.getLibraries()) {
|
||||
String libraryId = library.getLibraryId();
|
||||
if (!controller.getSettings().containsKey(libraryId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
LibraryAnalyzer.LibraryType libraryType = LibraryAnalyzer.LibraryType.fromPatchId(libraryId);
|
||||
if (libraryType != null) {
|
||||
java.io.File versionRoot = repository.getVersionRoot(versionName);
|
||||
switch (libraryType) {
|
||||
case FORGE:
|
||||
case NEO_FORGE:
|
||||
case FABRIC:
|
||||
case QUILT:
|
||||
case LITELOADER:
|
||||
new java.io.File(versionRoot, "mods").mkdirs();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user