TODOs
This commit is contained in:
parent
2e740e1117
commit
1d25d36ac7
|
@ -8,7 +8,10 @@ import imgui.flag.ImGuiConfigFlags;
|
|||
import imgui.gl3.ImGuiImplGl3;
|
||||
import imgui.glfw.ImGuiImplGlfw;
|
||||
import io.gitlab.jfronny.glaunch.gson.MinecraftArgumentDeserializer;
|
||||
import io.gitlab.jfronny.glaunch.gson.RulesDeserializer;
|
||||
import io.gitlab.jfronny.glaunch.model.MinecraftArgument;
|
||||
import io.gitlab.jfronny.glaunch.model.Rules;
|
||||
import io.gitlab.jfronny.glaunch.util.Utils;
|
||||
import io.gitlab.jfronny.glaunch.windows.MainWindow;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
@ -30,20 +33,25 @@ import java.util.Set;
|
|||
//TODO mods browser
|
||||
//TODO load and launch instance from metadata
|
||||
//TODO allow instance sync through metadata
|
||||
//TODO update checker
|
||||
public class GLaunch {
|
||||
public static final Set<Window> WINDOWS = new LinkedHashSet<>();
|
||||
public static final Logger LOGGER = LogManager.getFormatterLogger("GLaunch");
|
||||
public static final Gson GSON = new GsonBuilder()
|
||||
.registerTypeAdapter(MinecraftArgument.class, new MinecraftArgumentDeserializer())
|
||||
.registerTypeAdapter(Rules.class, new RulesDeserializer())
|
||||
.create();
|
||||
public static final Path CACHE_DIR = Path.of("run/cache");
|
||||
public static final Path INSTANCE_DIR = Path.of("run/instances");
|
||||
public static final Path ASSETS_DIR = Path.of("run/assets");
|
||||
public static final Path LIBRARIES_DIR = Path.of("run/libraries");
|
||||
public static final Config CONFIG = new Config(); //TODO from gson
|
||||
private static final Path CONFIG_PATH = Path.of("glaunch2.json");
|
||||
public static Config CONFIG;
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
LOGGER.info("Setting up cache dir");
|
||||
if (!Files.exists(CONFIG_PATH)) Utils.writeObject(CONFIG_PATH, new Config());
|
||||
CONFIG = Utils.loadObject(CONFIG_PATH, Config.class);
|
||||
if (!Files.exists(CACHE_DIR)) Files.createDirectories(CACHE_DIR);
|
||||
if (!Files.exists(INSTANCE_DIR)) Files.createDirectories(INSTANCE_DIR);
|
||||
if (!Files.exists(ASSETS_DIR)) Files.createDirectories(ASSETS_DIR);
|
||||
|
|
|
@ -3,7 +3,6 @@ package io.gitlab.jfronny.glaunch.gson;
|
|||
import com.google.gson.*;
|
||||
import io.gitlab.jfronny.glaunch.model.MinecraftArgument;
|
||||
import io.gitlab.jfronny.glaunch.model.Rules;
|
||||
import io.gitlab.jfronny.glaunch.util.Utils;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.LinkedHashSet;
|
||||
|
@ -19,31 +18,6 @@ public class MinecraftArgumentDeserializer implements JsonDeserializer<Minecraft
|
|||
JsonObject jo = json.getAsJsonObject();
|
||||
if (jo.size() != 2 || !jo.has("rules") || !jo.has("value"))
|
||||
throw new JsonParseException("Not a valid minecraft argument");
|
||||
/*boolean valid = true;
|
||||
for (JsonElement rule : jo.get("rules").getAsJsonArray()) {
|
||||
JsonObject ro = rule.getAsJsonObject();
|
||||
if (!ro.get("action").getAsJsonPrimitive().getAsString().equals("allow"))
|
||||
throw new JsonParseException("Unexpected action in argument");
|
||||
if (ro.has("features")) { //TODO support has_custom_resolution
|
||||
valid = false;
|
||||
continue;
|
||||
}
|
||||
if (ro.has("os")) {
|
||||
JsonObject osObject = ro.get("os").getAsJsonObject();
|
||||
if (osObject.has("name")) {
|
||||
if (!Utils.getOs().equals(osObject.get("name").getAsString())) {
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (osObject.has("version")) {
|
||||
if (!System.getProperty("os.version").matches(osObject.get("version").getAsString())) {
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
Rules r = context.deserialize(jo.get("rules"), Rules.class);
|
||||
if (!r.allow()) return new MinecraftArgument(Set.of());
|
||||
Set<String> sel = new LinkedHashSet<>();
|
||||
|
|
|
@ -3,35 +3,7 @@ package io.gitlab.jfronny.glaunch.install;
|
|||
import io.gitlab.jfronny.glaunch.model.VersionInfo;
|
||||
import io.gitlab.jfronny.glaunch.windows.NewInstanceWindow;
|
||||
|
||||
public final class SetupStepInfo {
|
||||
private final VersionInfo version;
|
||||
private final NewInstanceWindow.LoaderType loaderType;
|
||||
private final String name;
|
||||
private String classpath;
|
||||
|
||||
public SetupStepInfo(VersionInfo version, NewInstanceWindow.LoaderType loaderType, String name) {
|
||||
this.version = version;
|
||||
this.loaderType = loaderType;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public VersionInfo getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public NewInstanceWindow.LoaderType getLoaderType() {
|
||||
return loaderType;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setClasspath(String classpath) {
|
||||
this.classpath = classpath;
|
||||
}
|
||||
|
||||
public String getClasspath() {
|
||||
return classpath;
|
||||
}
|
||||
public record SetupStepInfo(VersionInfo version,
|
||||
NewInstanceWindow.LoaderType loaderType,
|
||||
String name) {
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ public class DownloadAssetsStep implements Step {
|
|||
public void execute(SetupStepInfo info) throws IOException {
|
||||
//TODO feedback
|
||||
Path o = GLaunch.ASSETS_DIR.resolve("objects");
|
||||
for (Map.Entry<String, AssetIndex.Asset> entry : McApi.getAssetIndex(info.getVersion()).objects.entrySet()) {
|
||||
for (Map.Entry<String, AssetIndex.Asset> entry : McApi.getAssetIndex(info.version()).objects.entrySet()) {
|
||||
Path fPath = o.resolve(entry.getValue().hash.substring(0, 2));
|
||||
if (!Files.exists(fPath)) Files.createDirectories(fPath);
|
||||
McApi.downloadAsset(entry.getValue(), fPath.resolve(entry.getValue().hash));
|
||||
|
|
|
@ -11,7 +11,7 @@ import java.io.IOException;
|
|||
public class DownloadClientStep implements Step {
|
||||
@Override
|
||||
public void execute(SetupStepInfo info) throws IOException {
|
||||
VersionInfo.Downloads.Download client = info.getVersion().downloads.client;
|
||||
Utils.downloadFile(client.url, client.sha1, GLaunch.LIBRARIES_DIR.resolve(info.getVersion().id + ".jar"));
|
||||
VersionInfo.Downloads.Download client = info.version().downloads.client;
|
||||
Utils.downloadFile(client.url, client.sha1, GLaunch.LIBRARIES_DIR.resolve(info.version().id + ".jar"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,9 +12,8 @@ import java.io.IOException;
|
|||
public class DownloadLibrariesStep implements Step {
|
||||
@Override
|
||||
public void execute(SetupStepInfo info) throws IOException {
|
||||
//TODO info.setClasspath("");
|
||||
//TODO feedback
|
||||
mainLoop: for (VersionInfo.Library library : info.getVersion().libraries) {
|
||||
mainLoop: for (VersionInfo.Library library : info.version().libraries) {
|
||||
for (Rules rule : library.rules) {
|
||||
if (!rule.allow()) continue mainLoop;
|
||||
}
|
||||
|
|
|
@ -11,8 +11,14 @@ import java.nio.file.Path;
|
|||
public class SetupDirsStep implements Step {
|
||||
@Override
|
||||
public void execute(SetupStepInfo info) throws IOException {
|
||||
Path iDir = GLaunch.INSTANCE_DIR.resolve(info.getName());
|
||||
if (!Files.exists(iDir))
|
||||
Path iDir = GLaunch.INSTANCE_DIR.resolve(info.name());
|
||||
if (!Files.exists(iDir)) {
|
||||
Files.createDirectories(iDir);
|
||||
Files.createDirectories(iDir.resolve("config"));
|
||||
Files.createDirectories(iDir.resolve("mods"));
|
||||
Files.createDirectories(iDir.resolve("resourcepacks"));
|
||||
Files.createDirectories(iDir.resolve("saves"));
|
||||
Files.createDirectories(iDir.resolve("screenshots"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,10 +12,10 @@ import java.nio.file.Path;
|
|||
public class WriteMetadataStep implements Step {
|
||||
@Override
|
||||
public void execute(SetupStepInfo info) throws IOException {
|
||||
Path metaDir = GLaunch.INSTANCE_DIR.resolve(info.getName()).resolve("instance.json");
|
||||
Path metaDir = GLaunch.INSTANCE_DIR.resolve(info.name()).resolve("instance.json");
|
||||
InstanceMeta meta = new InstanceMeta();
|
||||
meta.loaderType = info.getLoaderType();
|
||||
meta.version = info.getVersion().id;
|
||||
meta.loaderType = info.loaderType();
|
||||
meta.version = info.version().id;
|
||||
Utils.writeObject(metaDir, meta);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue