diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/BaseMainActivity.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/BaseMainActivity.java index 5ed082ce7..ad1c72f5e 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/BaseMainActivity.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/BaseMainActivity.java @@ -31,6 +31,7 @@ import net.kdt.pojavlaunch.profiles.ProfileAdapter; import net.kdt.pojavlaunch.utils.*; import net.kdt.pojavlaunch.value.*; import net.kdt.pojavlaunch.value.launcherprofiles.LauncherProfiles; +import net.kdt.pojavlaunch.value.launcherprofiles.MinecraftProfile; import org.lwjgl.glfw.*; @@ -48,7 +49,7 @@ public class BaseMainActivity extends BaseActivity { private static Touchpad touchpad; private LoggerView loggerView; - private MinecraftAccount mProfile; + MinecraftAccount mProfile; private DrawerLayout drawerLayout; private NavigationView navDrawer; @@ -58,7 +59,7 @@ public class BaseMainActivity extends BaseActivity { protected volatile JMinecraftVersionList.Version mVersionInfo; - private PerVersionConfig.VersionConfig config; + //private PerVersionConfig.VersionConfig config; protected void initLayout(int resId) { setContentView(resId); @@ -70,28 +71,44 @@ public class BaseMainActivity extends BaseActivity { loggerView = findViewById(R.id.mainLoggerView); mProfile = PojavProfile.getCurrentProfileContent(this); + String runtime = LauncherPreferences.PREF_DEFAULT_RUNTIME; if(!LauncherPreferences.PREF_ENABLE_PROFILES) { mVersionInfo = Tools.getVersionInfo(null, mProfile.selectedVersion); + PerVersionConfig.update(); + PerVersionConfig.VersionConfig config = PerVersionConfig.configMap.get(mProfile.selectedVersion); + if(config != null) { + if(config.selectedRuntime != null) { + if(MultiRTUtils.forceReread(config.selectedRuntime).versionString != null) { + runtime = config.selectedRuntime; + } + } + if(config.renderer != null) { + Tools.LOCAL_RENDERER = config.renderer; + } + } }else{ LauncherProfiles.update(); + MinecraftProfile prof = LauncherProfiles.mainProfileJson.profiles.get(mProfile.selectedProfile); + if(prof == null) { + Toast.makeText(this,"Attempted to launch nonexistent profile",Toast.LENGTH_SHORT).show(); + finish(); + return; + } mVersionInfo = Tools.getVersionInfo(null, BaseLauncherActivity.getVersionId( - LauncherProfiles.mainProfileJson.profiles.get(mProfile.selectedProfile).lastVersionId)); + prof.lastVersionId)); + if(prof.javaDir != null && prof.javaDir.startsWith(Tools.LAUNCHERPROFILES_RTPREFIX)) { + String runtimeName = prof.javaDir.substring(Tools.LAUNCHERPROFILES_RTPREFIX.length()); + if(MultiRTUtils.forceReread(runtimeName).versionString != null) { + runtime = runtimeName; + } + } + if(prof.__P_renderer_name != null) { + Tools.LOCAL_RENDERER = prof.__P_renderer_name; + } } setTitle("Minecraft " + mProfile.selectedVersion); - PerVersionConfig.update(); - config = PerVersionConfig.configMap.get(mProfile.selectedVersion); - String runtime = LauncherPreferences.PREF_DEFAULT_RUNTIME; - if(config != null) { - if(config.selectedRuntime != null) { - if(MultiRTUtils.forceReread(config.selectedRuntime).versionString != null) { - runtime = config.selectedRuntime; - } - } - if(config.renderer != null) { - Tools.LOCAL_RENDERER = config.renderer; - } - } + MultiRTUtils.setRuntimeNamed(this,runtime); // Minecraft 1.13+ isInputStackCall = mVersionInfo.arguments != null; diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Tools.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Tools.java index 1babf3680..c5068a150 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Tools.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Tools.java @@ -23,6 +23,7 @@ import net.kdt.pojavlaunch.prefs.*; import net.kdt.pojavlaunch.utils.*; import net.kdt.pojavlaunch.value.*; import net.kdt.pojavlaunch.value.launcherprofiles.LauncherProfiles; +import net.kdt.pojavlaunch.value.launcherprofiles.MinecraftProfile; import org.apache.commons.codec.binary.Hex; import org.apache.commons.codec.digest.DigestUtils; @@ -50,6 +51,7 @@ public final class Tools { public static String MULTIRT_HOME; public static String LOCAL_RENDERER = null; public static int DEVICE_ARCHITECTURE; + public static String LAUNCHERPROFILES_RTPREFIX = "pojav://"; // New since 3.3.1 public static String DIR_ACCOUNT_NEW; @@ -117,13 +119,25 @@ public final class Tools { } JMinecraftVersionList.Version versionInfo = Tools.getVersionInfo(null,versionName); - PerVersionConfig.update(); - PerVersionConfig.VersionConfig pvcConfig = PerVersionConfig.configMap.get(versionName); - - String gamedirPath; - if(pvcConfig != null && pvcConfig.gamePath != null && !pvcConfig.gamePath.isEmpty()) gamedirPath = pvcConfig.gamePath; - else gamedirPath = Tools.DIR_GAME_NEW; - if(pvcConfig != null && pvcConfig.jvmArgs != null && !pvcConfig.jvmArgs.isEmpty()) LauncherPreferences.PREF_CUSTOM_JAVA_ARGS = pvcConfig.jvmArgs; + String gamedirPath = Tools.DIR_GAME_NEW; + if(!LauncherPreferences.PREF_ENABLE_PROFILES) { + PerVersionConfig.update(); + PerVersionConfig.VersionConfig pvcConfig = PerVersionConfig.configMap.get(versionName); + if (pvcConfig != null && pvcConfig.gamePath != null && !pvcConfig.gamePath.isEmpty()) + gamedirPath = pvcConfig.gamePath; + if (pvcConfig != null && pvcConfig.jvmArgs != null && !pvcConfig.jvmArgs.isEmpty()) + LauncherPreferences.PREF_CUSTOM_JAVA_ARGS = pvcConfig.jvmArgs; + }else{ + if(activity instanceof BaseMainActivity) { + LauncherProfiles.update(); + MinecraftProfile prof = LauncherProfiles.mainProfileJson.profiles.get(((BaseMainActivity)activity).mProfile.selectedProfile); + if(prof == null) throw new Exception("Launching empty Profile"); + if(prof.gameDir != null && !prof.gameDir.isEmpty()) + gamedirPath = prof.gameDir; + if(prof.javaArgs != null && !prof.javaArgs.isEmpty()) + LauncherPreferences.PREF_CUSTOM_JAVA_ARGS = prof.javaArgs; + } + } PojavLoginActivity.disableSplash(gamedirPath); String[] launchArgs = getMinecraftArgs(profile, versionInfo, gamedirPath); diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/tasks/MinecraftDownloaderTask.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/tasks/MinecraftDownloaderTask.java index 71c6cf247..661b563a9 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/tasks/MinecraftDownloaderTask.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/tasks/MinecraftDownloaderTask.java @@ -16,6 +16,7 @@ import net.kdt.pojavlaunch.prefs.*; import net.kdt.pojavlaunch.utils.*; import net.kdt.pojavlaunch.value.*; import net.kdt.pojavlaunch.value.launcherprofiles.LauncherProfiles; +import net.kdt.pojavlaunch.value.launcherprofiles.MinecraftProfile; import org.apache.commons.io.*; @@ -91,18 +92,40 @@ public class MinecraftDownloaderTask extends AsyncTask{ AlertDialog.Builder bldr = new AlertDialog.Builder(mActivity); diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/V117CompatUtil.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/V117CompatUtil.java index 8efb35cd0..3ef343f77 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/V117CompatUtil.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/V117CompatUtil.java @@ -7,11 +7,14 @@ import android.util.Log; import androidx.appcompat.app.AlertDialog; +import net.kdt.pojavlaunch.BaseLauncherActivity; import net.kdt.pojavlaunch.R; import net.kdt.pojavlaunch.Tools; import net.kdt.pojavlaunch.prefs.LauncherPreferences; import net.kdt.pojavlaunch.tasks.MinecraftDownloaderTask; import net.kdt.pojavlaunch.value.PerVersionConfig; +import net.kdt.pojavlaunch.value.launcherprofiles.LauncherProfiles; +import net.kdt.pojavlaunch.value.launcherprofiles.MinecraftProfile; import org.apache.commons.io.IOUtils; @@ -103,11 +106,25 @@ public class V117CompatUtil { } public static void runCheck(String version, Activity ctx) throws Exception{ - PerVersionConfig.VersionConfig cfg = PerVersionConfig.configMap.get(version); + MCOptionUtils.load(); List packList =getTexturePackList(MCOptionUtils.get("resourcePacks")); - String renderer = cfg != null && cfg.renderer != null?cfg.renderer:LauncherPreferences.PREF_RENDERER; + String renderer; + String gamePath; + if(!LauncherPreferences.PREF_ENABLE_PROFILES) { + PerVersionConfig.update(); + PerVersionConfig.VersionConfig cfg = PerVersionConfig.configMap.get(version); + renderer = cfg != null && cfg.renderer != null?cfg.renderer:LauncherPreferences.PREF_RENDERER; + gamePath = cfg != null && cfg.gamePath != null?cfg.gamePath:Tools.DIR_GAME_NEW; + }else{ + LauncherProfiles.update(); + MinecraftProfile prof = LauncherProfiles.mainProfileJson.profiles.get(((BaseLauncherActivity)ctx).mProfile.selectedProfile); + if(prof == null) throw new MinecraftDownloaderTask.SilentException(); + renderer = prof.__P_renderer_name != null?prof.__P_renderer_name:LauncherPreferences.PREF_RENDERER; + gamePath = prof.gameDir != null?prof.gameDir:Tools.DIR_GAME_NEW; + } + //String if(renderer.equals("vulkan_zink") || renderer.equals("opengles3_virgl")) return; //don't install for zink/virgl users; if(packList.contains("\"assets-v0.zip\"") && renderer.equals("opengles3")) return; @@ -141,14 +158,21 @@ public class V117CompatUtil { } switch(proceed.get()) { case 1: - if (cfg == null) { - cfg = new PerVersionConfig.VersionConfig(); - PerVersionConfig.configMap.put(version, cfg); + if(!LauncherPreferences.PREF_ENABLE_PROFILES) { + PerVersionConfig.VersionConfig cfg = PerVersionConfig.configMap.get(version); + if (cfg == null) { + cfg = new PerVersionConfig.VersionConfig(); + PerVersionConfig.configMap.put(version, cfg); + } + cfg.renderer = "opengles3"; + PerVersionConfig.update(); + }else{ + MinecraftProfile prof = LauncherProfiles.mainProfileJson.profiles.get(((BaseLauncherActivity)ctx).mProfile.selectedProfile); + if(prof == null) throw new MinecraftDownloaderTask.SilentException(); + prof.__P_renderer_name = "opengles3"; + LauncherProfiles.update(); } - cfg.renderer = "opengles3"; - String path = Tools.DIR_GAME_NEW; - if(cfg.gamePath != null && !cfg.gamePath.isEmpty()) path = cfg.gamePath; - copyResourcePack(path,ctx.getAssets()); + copyResourcePack(gamePath,ctx.getAssets()); if(!packList.contains("\"assets-v0.zip\"")) packList.add(0,"\"assets-v0.zip\""); MCOptionUtils.set("resourcePacks",regenPackList(packList)); MCOptionUtils.save(); diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/value/launcherprofiles/MinecraftProfile.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/value/launcherprofiles/MinecraftProfile.java index d2fe3cf4c..36c2c124e 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/value/launcherprofiles/MinecraftProfile.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/value/launcherprofiles/MinecraftProfile.java @@ -13,5 +13,6 @@ public class MinecraftProfile public String javaArgs; public String logConfig; public boolean logConfigIsXML; + public String __P_renderer_name; public MinecraftResolution[] resolution; }