2022-09-04 21:21:24 +02:00
|
|
|
package io.gitlab.jfronny.inceptum.imgui.window;
|
2021-10-27 22:00:08 +02:00
|
|
|
|
2022-01-18 19:22:26 +01:00
|
|
|
import imgui.ImGui;
|
2022-09-04 21:21:24 +02:00
|
|
|
import io.gitlab.jfronny.inceptum.common.R;
|
|
|
|
import io.gitlab.jfronny.inceptum.common.Utils;
|
2022-09-19 21:26:23 +02:00
|
|
|
import io.gitlab.jfronny.inceptum.imgui.GuiMain;
|
2022-09-04 21:21:24 +02:00
|
|
|
import io.gitlab.jfronny.inceptum.imgui.control.InstanceManageControls;
|
2022-09-19 21:26:23 +02:00
|
|
|
import io.gitlab.jfronny.inceptum.imgui.window.dialog.ProcessStateWatcherWindow;
|
|
|
|
import io.gitlab.jfronny.inceptum.launcher.LauncherEnv;
|
|
|
|
import io.gitlab.jfronny.inceptum.launcher.system.importer.Importers;
|
2022-10-27 20:54:55 +02:00
|
|
|
import io.gitlab.jfronny.inceptum.launcher.system.setup.SetupStepInfo;
|
|
|
|
import io.gitlab.jfronny.inceptum.launcher.system.setup.Steps;
|
2022-09-19 21:26:23 +02:00
|
|
|
import io.gitlab.jfronny.inceptum.launcher.util.ProcessState;
|
2021-10-27 22:00:08 +02:00
|
|
|
|
|
|
|
import java.io.IOException;
|
2022-09-19 21:26:23 +02:00
|
|
|
import java.nio.file.Path;
|
|
|
|
import java.util.List;
|
2021-10-27 22:00:08 +02:00
|
|
|
|
|
|
|
public class NewInstanceWindow extends Window {
|
2022-10-19 21:26:06 +02:00
|
|
|
private final InstanceManageControls imc = new InstanceManageControls(null);
|
2022-09-04 21:21:24 +02:00
|
|
|
|
2021-10-27 22:00:08 +02:00
|
|
|
public NewInstanceWindow() {
|
|
|
|
super("New Instance");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void draw() {
|
2022-01-18 19:22:26 +01:00
|
|
|
if (ImGui.beginTabBar("NewInstanceBar")) {
|
|
|
|
if (ImGui.beginTabItem("New")) {
|
|
|
|
imc.snapshotsBox();
|
2022-09-04 21:21:24 +02:00
|
|
|
imc.versionBox(R::nop);
|
2022-01-18 19:22:26 +01:00
|
|
|
imc.nameBox("OK", name -> {
|
|
|
|
try {
|
2022-01-19 19:14:13 +01:00
|
|
|
GuiUtil.createInstance(new SetupStepInfo(imc.getVersionInfo(),
|
2022-01-18 19:22:26 +01:00
|
|
|
imc.getLoaderInfo(),
|
|
|
|
name,
|
2022-01-19 19:14:13 +01:00
|
|
|
Steps.createProcessState()));
|
2022-01-18 19:22:26 +01:00
|
|
|
} catch (IOException e) {
|
|
|
|
Utils.LOGGER.error("Could not initialize instance creation", e);
|
|
|
|
}
|
|
|
|
close();
|
|
|
|
});
|
|
|
|
ImGui.endTabItem();
|
2021-10-27 22:00:08 +02:00
|
|
|
}
|
2022-01-27 17:05:32 +01:00
|
|
|
if (ImGui.beginTabItem("Import")) {
|
2022-08-02 16:55:16 +02:00
|
|
|
ImGui.text("You can also just add an instance directory and it'll be loaded automatically");
|
|
|
|
ImGui.text("Using git to manage it is recommended if you do so");
|
|
|
|
ImGui.spacing();
|
2022-09-19 21:26:23 +02:00
|
|
|
ImGui.text("Below, you can import a CurseForge, Modrinth or MultiMC pack");
|
|
|
|
if (ImGui.button("Import")) {
|
|
|
|
List<Path> packs = GuiMain.openFileDialog("Import Pack", null, new String[] {"*.zip", "*.mrpack"}, "Modpack", true);
|
|
|
|
if (!packs.isEmpty()) {
|
|
|
|
ProcessState state = new ProcessState(Importers.MAX_STEPS * packs.size(), "Initializing");
|
|
|
|
GuiMain.open(new ProcessStateWatcherWindow("Importing", "Could not import packs", state, cToken -> {
|
|
|
|
for (Path pack : packs) {
|
|
|
|
Path imported = Importers.importPack(pack, state);
|
|
|
|
LauncherEnv.showInfo(pack.getFileName() + " has been successfully imported as " + imported.getFileName(), "Imported pack");
|
|
|
|
}
|
|
|
|
}, null));
|
|
|
|
}
|
|
|
|
}
|
2022-01-18 19:22:26 +01:00
|
|
|
ImGui.endTabItem();
|
|
|
|
}
|
|
|
|
ImGui.endTabBar();
|
|
|
|
}
|
2021-10-27 22:00:08 +02:00
|
|
|
}
|
|
|
|
}
|