Updating actually works now (maybe)
This commit is contained in:
parent
6e473a19ee
commit
60c5a30868
|
@ -35,11 +35,11 @@ public class InceptumGui {
|
|||
protected static long handle;
|
||||
private static String glslVersion = null;
|
||||
|
||||
public static void main(CommandArguments args) {
|
||||
public static void main(CommandArguments args, Runnable exec) {
|
||||
AccountManager.loadAccounts();
|
||||
Inceptum.LOGGER.info("Initializing UI");
|
||||
InceptumGui.WINDOWS.add(new MainWindow());
|
||||
InceptumGui.init();
|
||||
exec.run();
|
||||
InceptumGui.run();
|
||||
InceptumGui.dispose();
|
||||
}
|
||||
|
@ -133,7 +133,6 @@ public class InceptumGui {
|
|||
ImGui.createContext();
|
||||
ImGuiIO io = ImGui.getIO();
|
||||
io.addConfigFlags(ImGuiConfigFlags.ViewportsEnable);
|
||||
//io.setConfigViewportsNoDecoration(false);
|
||||
io.setConfigViewportsNoAutoMerge(true);
|
||||
//TODO use included icons (https://www.nerdfonts.com/cheat-sheet)
|
||||
//Nerd Fonts-patched ubuntu font
|
||||
|
|
|
@ -4,6 +4,7 @@ import io.gitlab.jfronny.inceptum.Inceptum;
|
|||
import io.gitlab.jfronny.inceptum.InceptumGui;
|
||||
import io.gitlab.jfronny.inceptum.model.inceptum.CommandArguments;
|
||||
import io.gitlab.jfronny.inceptum.model.inceptum.UpdateInfo;
|
||||
import io.gitlab.jfronny.inceptum.windows.MainWindow;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
|
@ -17,18 +18,20 @@ public class GuiCommand extends Command {
|
|||
public void invoke(CommandArguments args) {
|
||||
Inceptum.IS_GUI = true;
|
||||
UpdateInfo update = UpdateCheckCommand.getUpdate();
|
||||
if (update == null) {
|
||||
InceptumGui.main(args);
|
||||
} else {
|
||||
Inceptum.showOkCancel("An update was found. Should it be installed automatically?", "Update found", () -> {
|
||||
try {
|
||||
UpdateCheckCommand.update(update, true);
|
||||
InceptumGui.exit();
|
||||
} catch (IOException | URISyntaxException e) {
|
||||
Inceptum.showError("Could not download update", e);
|
||||
}
|
||||
}, () -> InceptumGui.main(args));
|
||||
}
|
||||
InceptumGui.main(args, () -> {
|
||||
if (update == null) {
|
||||
InceptumGui.WINDOWS.add(new MainWindow());
|
||||
} else {
|
||||
Inceptum.showOkCancel("An update was found. Should it be installed automatically?", "Update found", () -> {
|
||||
try {
|
||||
UpdateCheckCommand.update(update, true);
|
||||
InceptumGui.exit();
|
||||
} catch (IOException | URISyntaxException e) {
|
||||
Inceptum.showError("Could not download update", e);
|
||||
}
|
||||
}, () -> InceptumGui.WINDOWS.add(new MainWindow()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -10,8 +10,8 @@ import io.gitlab.jfronny.inceptum.util.UpdateChecker;
|
|||
import io.gitlab.jfronny.inceptum.util.Utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class UpdateCheckCommand extends Command {
|
||||
|
@ -53,23 +53,22 @@ public class UpdateCheckCommand extends Command {
|
|||
}
|
||||
|
||||
public static void update(UpdateInfo source, boolean relaunch) throws IOException, URISyntaxException {
|
||||
if (OSCheck.OS == OSType.WINDOWS) {
|
||||
String path = UpdateCheckCommand.class.getProtectionDomain().getCodeSource().getLocation().getPath();
|
||||
if (!path.endsWith(".jar")) throw new IOException("Inceptum is not running in a proper jar file");
|
||||
Utils.downloadFile(source.url(), source.sha1(), Path.of(path));
|
||||
}
|
||||
else {
|
||||
Utils.openWebBrowser(new URI(source.url()));
|
||||
Inceptum.LOGGER.info("Downloading " + source.url());
|
||||
Path jarPath = Inceptum.LIBRARIES_DIR.resolve("io/gitlab/jfronny/inceptum/Inceptum")
|
||||
.resolve(source.newVersion().toString())
|
||||
.resolve("Inceptum-" + source.newVersion() + '-' + OSCheck.OS.getMojName() + ".jar")
|
||||
.toAbsolutePath();
|
||||
Files.createDirectories(jarPath.getParent());
|
||||
Utils.downloadFile(source.url(), source.sha1(), jarPath);
|
||||
if (relaunch) {
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
try {
|
||||
Runtime.getRuntime().exec(new String[] {
|
||||
JvmUtils.getJvm(),
|
||||
System.out.println();
|
||||
new ProcessBuilder(JvmUtils.getJvm(),
|
||||
"-jar",
|
||||
Inceptum.LIBRARIES_DIR.resolve("io/gitlab/jfronny/inceptum/Inceptum")
|
||||
.resolve(source.newVersion().toString())
|
||||
.resolve("Inceptum-" + source.newVersion() + '-' + OSCheck.OS.getMojName() + ".jar")
|
||||
.toString()
|
||||
});
|
||||
jarPath.toString())
|
||||
.inheritIO()
|
||||
.start();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -60,10 +60,10 @@ public class Wrapper {
|
|||
System.err.println("Something went wrong, please try again");
|
||||
return;
|
||||
}
|
||||
Runtime.getRuntime().exec(new String[] {
|
||||
JvmUtils.getJvm(),
|
||||
new ProcessBuilder(JvmUtils.getJvm(),
|
||||
"-jar",
|
||||
pathChosen.resolve("Inceptum-" + chosenVer + '-' + OSCheck.OS.getMojName() + ".jar").toString()
|
||||
});
|
||||
pathChosen.resolve("Inceptum-" + chosenVer + '-' + OSCheck.OS.getMojName() + ".jar").toString())
|
||||
.inheritIO()
|
||||
.start();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue