- The game runs now
This commit is contained in:
artdeell 2021-12-05 15:13:06 +03:00
parent 213c6a7f84
commit 9608545111
5 changed files with 57 additions and 13 deletions

View file

@ -18,6 +18,7 @@ import androidx.appcompat.app.*;
import com.kdt.pickafile.*; import com.kdt.pickafile.*;
import java.io.*; import java.io.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Map;
import net.kdt.pojavlaunch.extra.ExtraCore; import net.kdt.pojavlaunch.extra.ExtraCore;
import net.kdt.pojavlaunch.extra.ExtraListener; import net.kdt.pojavlaunch.extra.ExtraListener;
@ -31,6 +32,8 @@ import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.PopupMenu; import androidx.appcompat.widget.PopupMenu;
import net.kdt.pojavlaunch.value.*; import net.kdt.pojavlaunch.value.*;
import net.kdt.pojavlaunch.value.launcherprofiles.LauncherProfiles;
import net.kdt.pojavlaunch.value.launcherprofiles.MinecraftProfile;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
@ -106,11 +109,34 @@ public abstract class BaseLauncherActivity extends BaseActivity {
} else if (canBack) { } else if (canBack) {
v.setEnabled(false); v.setEnabled(false);
mTask = new MinecraftDownloaderTask(this); mTask = new MinecraftDownloaderTask(this);
mTask.execute(mProfile.selectedVersion); if(LauncherPreferences.PREF_ENABLE_PROFILES) {
LauncherProfiles.update();
if (LauncherProfiles.mainProfileJson != null && LauncherProfiles.mainProfileJson.profiles != null && LauncherProfiles.mainProfileJson.profiles.containsKey(mProfile.selectedProfile + "")) {
MinecraftProfile prof = LauncherProfiles.mainProfileJson.profiles.get(mProfile.selectedProfile + "");
if (prof != null && prof.lastVersionId != null) {
mTask.execute(getVersionId(prof.lastVersionId));
}
}
}else{
mTask.execute(mProfile.selectedProfile);
}
} }
} }
public static String getVersionId(String input) {
Map<String,String> lReleaseMaps = (Map<String,String>)ExtraCore.getValue("release_table");
if(lReleaseMaps == null || lReleaseMaps.isEmpty()) return input;
switch(input) {
case "latest-release":
return lReleaseMaps.get("release");
case "latest-snapshot":
return lReleaseMaps.get("snapshot");
default:
return input;
}
}
@Override @Override
public void onBackPressed() { public void onBackPressed() {
if (canBack) { if (canBack) {

View file

@ -27,8 +27,11 @@ import net.kdt.pojavlaunch.customcontrols.*;
import net.kdt.pojavlaunch.multirt.MultiRTUtils; import net.kdt.pojavlaunch.multirt.MultiRTUtils;
import net.kdt.pojavlaunch.prefs.*; import net.kdt.pojavlaunch.prefs.*;
import net.kdt.pojavlaunch.profiles.ProfileAdapter;
import net.kdt.pojavlaunch.utils.*; import net.kdt.pojavlaunch.utils.*;
import net.kdt.pojavlaunch.value.*; import net.kdt.pojavlaunch.value.*;
import net.kdt.pojavlaunch.value.launcherprofiles.LauncherProfiles;
import org.lwjgl.glfw.*; import org.lwjgl.glfw.*;
public class BaseMainActivity extends BaseActivity { public class BaseMainActivity extends BaseActivity {
@ -59,7 +62,7 @@ public class BaseMainActivity extends BaseActivity {
protected void initLayout(int resId) { protected void initLayout(int resId) {
setContentView(resId); setContentView(resId);
ProfileAdapter.clearIconCache();
try { try {
Logger.getInstance().reset(); Logger.getInstance().reset();
// FIXME: is it safe fot multi thread? // FIXME: is it safe fot multi thread?
@ -68,7 +71,13 @@ public class BaseMainActivity extends BaseActivity {
loggerView = findViewById(R.id.mainLoggerView); loggerView = findViewById(R.id.mainLoggerView);
mProfile = PojavProfile.getCurrentProfileContent(this); mProfile = PojavProfile.getCurrentProfileContent(this);
mVersionInfo = Tools.getVersionInfo(null,mProfile.selectedVersion); if(!LauncherPreferences.PREF_ENABLE_PROFILES) {
mVersionInfo = Tools.getVersionInfo(null, mProfile.selectedVersion);
}else{
LauncherProfiles.update();
mVersionInfo = Tools.getVersionInfo(null, BaseLauncherActivity.getVersionId(
LauncherProfiles.mainProfileJson.profiles.get(mProfile.selectedProfile).lastVersionId));
}
setTitle("Minecraft " + mProfile.selectedVersion); setTitle("Minecraft " + mProfile.selectedVersion);
PerVersionConfig.update(); PerVersionConfig.update();
@ -187,7 +196,14 @@ public class BaseMainActivity extends BaseActivity {
"" : " (" + mVersionInfo.inheritsFrom + ")")); "" : " (" + mVersionInfo.inheritsFrom + ")"));
JREUtils.redirectAndPrintJRELog(this); JREUtils.redirectAndPrintJRELog(this);
if(!LauncherPreferences.PREF_ENABLE_PROFILES){
Tools.launchMinecraft(this, mProfile, mProfile.selectedVersion); Tools.launchMinecraft(this, mProfile, mProfile.selectedVersion);
}else{
LauncherProfiles.update();
Tools.launchMinecraft(this, mProfile, BaseLauncherActivity.getVersionId(
LauncherProfiles.mainProfileJson.profiles.get(mProfile.selectedProfile).lastVersionId));
}
} }
private void checkJavaArgsIsLaunchable(String jreVersion) throws Throwable { private void checkJavaArgsIsLaunchable(String jreVersion) throws Throwable {

View file

@ -57,7 +57,15 @@ public class ProfileAdapter extends BaseAdapter {
public int getCount() { public int getCount() {
return profileList.size(); return profileList.size();
} }
public static void clearIconCache() {
for(String s : iconCache.keySet()) {
Bitmap bmp = iconCache.get(s);
if(bmp != null) {
bmp.recycle();
}
}
iconCache.clear();
}
/* /*
* Gets the profile at a given index * Gets the profile at a given index
* @param position index to retreive * @param position index to retreive

View file

@ -16,19 +16,13 @@ import androidx.annotation.Nullable;
import net.kdt.pojavlaunch.BaseLauncherActivity; import net.kdt.pojavlaunch.BaseLauncherActivity;
import net.kdt.pojavlaunch.PojavLauncherActivity; import net.kdt.pojavlaunch.PojavLauncherActivity;
import net.kdt.pojavlaunch.PojavProfile;
import net.kdt.pojavlaunch.R; import net.kdt.pojavlaunch.R;
import net.kdt.pojavlaunch.extra.ExtraCore; import net.kdt.pojavlaunch.extra.ExtraCore;
import net.kdt.pojavlaunch.extra.ExtraListener; import net.kdt.pojavlaunch.extra.ExtraListener;
import net.kdt.pojavlaunch.tasks.RefreshVersionListTask;
import net.kdt.pojavlaunch.value.launcherprofiles.LauncherProfiles; import net.kdt.pojavlaunch.value.launcherprofiles.LauncherProfiles;
import net.kdt.pojavlaunch.value.launcherprofiles.MinecraftProfile; import net.kdt.pojavlaunch.value.launcherprofiles.MinecraftProfile;
import org.w3c.dom.Text;
import java.lang.reflect.Array;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;

View file

@ -3,7 +3,7 @@ package net.kdt.pojavlaunch.profiles;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
public class StringCRC64 { public class StringCRC64 {
private final static long POLY = (long) 0xc96c5795d7870f42L; // ECMA-182 private final static long POLY = 0xc96c5795d7870f42L; // ECMA-182
private final static long[][] table; private final static long[][] table;
static static
{ {