48 lines
2.4 KiB
Java
48 lines
2.4 KiB
Java
package io.gitlab.jfronny.inceptum.imgui.window.edit;
|
|
|
|
import imgui.ImGui;
|
|
import io.gitlab.jfronny.commons.ref.R;
|
|
import io.gitlab.jfronny.inceptum.imgui.GuiMain;
|
|
import io.gitlab.jfronny.inceptum.imgui.control.Tab;
|
|
import io.gitlab.jfronny.inceptum.imgui.window.dialog.ProcessStateWatcherWindow;
|
|
import io.gitlab.jfronny.inceptum.imgui.window.dialog.TextBoxWindow;
|
|
import io.gitlab.jfronny.inceptum.launcher.LauncherEnv;
|
|
import io.gitlab.jfronny.inceptum.launcher.system.exporter.Exporter;
|
|
import io.gitlab.jfronny.inceptum.launcher.system.exporter.Exporters;
|
|
import io.gitlab.jfronny.inceptum.launcher.util.ProcessState;
|
|
|
|
import java.nio.file.Path;
|
|
|
|
public class ExportTab extends Tab {
|
|
private final InstanceEditWindow window;
|
|
|
|
public ExportTab(InstanceEditWindow window) {
|
|
super("Export");
|
|
this.window = window;
|
|
}
|
|
|
|
@Override
|
|
protected void renderInner() {
|
|
if (window.instance.mds.isComplete) {
|
|
for (Exporter<?> exporter : Exporters.EXPORTERS) {
|
|
if (ImGui.button(exporter.name)) {
|
|
GuiMain.open(new TextBoxWindow("Version", "Please enter the current version of your modpack", "1.0", version -> {
|
|
String defaultName = window.instance.name + " " + version + " (" + exporter.name + ")." + exporter.fileExtension;
|
|
String filter = "*." + exporter.fileExtension;
|
|
Path exportPath = GuiMain.saveFileDialog("Export " + exporter.name + " Pack", defaultName, new String[]{filter}, exporter.name + " packs (" + filter + ")");
|
|
if (exportPath != null) {
|
|
ProcessState state = new ProcessState(Exporters.STEP_COUNT, "Initializing...");
|
|
GuiMain.open(new ProcessStateWatcherWindow("Exporting", "Could not export pack", state, cToken -> {
|
|
exporter.generate(state, window.instance, exportPath, version);
|
|
LauncherEnv.showInfo(window.instance.name + " has been successfully exported to " + exportPath, "Successfully exported");
|
|
}, null));
|
|
}
|
|
}, R::nop));
|
|
}
|
|
}
|
|
} else {
|
|
ImGui.text("The mods directory scan must be completed.\nThe progress for this can be observed in the mods tab");
|
|
}
|
|
}
|
|
}
|