A lot of changes

- Force profiles, no more profiles on/off switch!
- (probably partially) Conventionalize all profile changes
- Rename most variables for the changes to look nice
- Squash a couple null checks
- Separate cache from adapter and change how it works
- Don't keep Context
This commit is contained in:
artdeell 2022-03-17 19:03:38 +03:00
parent a4eabb69fc
commit 965cad4fd7
11 changed files with 206 additions and 274 deletions

View file

@ -27,7 +27,6 @@ import net.kdt.pojavlaunch.customcontrols.*;
import net.kdt.pojavlaunch.multirt.MultiRTUtils;
import net.kdt.pojavlaunch.prefs.*;
import net.kdt.pojavlaunch.profiles.ProfileAdapter;
import net.kdt.pojavlaunch.utils.*;
import net.kdt.pojavlaunch.value.*;
import net.kdt.pojavlaunch.value.launcherprofiles.LauncherProfiles;
@ -50,6 +49,7 @@ public class BaseMainActivity extends BaseActivity {
private LoggerView loggerView;
MinecraftAccount mProfile;
MinecraftProfile minecraftProfile;
private DrawerLayout drawerLayout;
private NavigationView navDrawer;
@ -71,44 +71,29 @@ public class BaseMainActivity extends BaseActivity {
loggerView = findViewById(R.id.mainLoggerView);
mProfile = PojavProfile.getCurrentProfileContent(this);
minecraftProfile = LauncherProfiles.mainProfileJson.profiles.get(mProfile.selectedProfile);
if(minecraftProfile == null) {
Toast.makeText(this,"Attempted to launch nonexistent profile",Toast.LENGTH_SHORT).show();
finish();
return;
}
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(
prof.lastVersionId));
if(prof.javaDir != null && prof.javaDir.startsWith(Tools.LAUNCHERPROFILES_RTPREFIX)) {
String runtimeName = prof.javaDir.substring(Tools.LAUNCHERPROFILES_RTPREFIX.length());
minecraftProfile.lastVersionId));
if(minecraftProfile.javaDir != null && minecraftProfile.javaDir.startsWith(Tools.LAUNCHERPROFILES_RTPREFIX)) {
String runtimeName = minecraftProfile.javaDir.substring(Tools.LAUNCHERPROFILES_RTPREFIX.length());
if(MultiRTUtils.forceReread(runtimeName).versionString != null) {
runtime = runtimeName;
}
}
if(prof.__P_renderer_name != null) {
Log.i("RdrDebug","__P_renderer="+prof.__P_renderer_name);
Tools.LOCAL_RENDERER = prof.__P_renderer_name;
if(minecraftProfile.pojavRendererName != null) {
Log.i("RdrDebug","__P_renderer="+minecraftProfile.pojavRendererName);
Tools.LOCAL_RENDERER = minecraftProfile.pojavRendererName;
}
}
setTitle("Minecraft " + mProfile.selectedVersion);
setTitle("Minecraft " + minecraftProfile.lastVersionId);
MultiRTUtils.setRuntimeNamed(this,runtime);
// Minecraft 1.13+
@ -231,14 +216,10 @@ public class BaseMainActivity extends BaseActivity {
"" : " (" + mVersionInfo.inheritsFrom + ")"));
JREUtils.redirectAndPrintJRELog(this);
if(!LauncherPreferences.PREF_ENABLE_PROFILES){
Tools.launchMinecraft(this, mProfile, mProfile.selectedVersion);
}else{
JREUtils.redirectAndPrintJRELog();
LauncherProfiles.update();
Tools.launchMinecraft(this, mProfile, BaseLauncherActivity.getVersionId(
LauncherProfiles.mainProfileJson.profiles.get(mProfile.selectedProfile).lastVersionId));
}
minecraftProfile.lastVersionId));
}
private void checkJavaArgsIsLaunchable(String jreVersion) throws Throwable {