GL4ES: HOLY EDITION

merge #3019
This commit is contained in:
ArtDev 2022-04-16 20:26:49 +03:00 committed by GitHub
commit ab6df38dbf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 211 additions and 240 deletions

View file

@ -25,88 +25,42 @@ jobs:
java-version: 1.8
- name: Get gl4es latest commit hash
if: github.ref == 'refs/heads/v3_openjdk'
id: gl4es-sha
run: echo "::set-output name=sha::$(echo $(git ls-remote https://github.com/PojavLauncherTeam/gl4es refs/heads/master | grep -io '^\S*'))"
run: echo "::set-output name=sha::$(echo $(git ls-remote https://github.com/PojavLauncherTeam/gl4es-114-extra refs/heads/master | grep -io '^\S*'))"
shell: bash
- name: Cache gl4es
if: github.ref == 'refs/heads/v3_openjdk'
uses: actions/cache@v2
id: gl4es-cache
with:
path: gl4es/libs
key: gl4es-android-shared-nodbg-test1-2-${{ steps.gl4es-sha.outputs.sha }}
key: gl4es-holy-android-shared-${{ steps.gl4es-sha.outputs.sha }}
- name: Get gl4es
if: github.ref == 'refs/heads/v3_openjdk' && steps.gl4es-cache.outputs.cache-hit != 'true'
if: steps.gl4es-cache.outputs.cache-hit != 'true'
uses: actions/checkout@v2
with:
repository: 'ptitSeb/gl4es'
repository: 'PojavLauncherTeam/gl4es-114-extra'
path: 'gl4es'
- name: Build gl4es
if: github.ref == 'refs/heads/v3_openjdk' && steps.gl4es-cache.outputs.cache-hit != 'true'
if: steps.gl4es-cache.outputs.cache-hit != 'true'
continue-on-error: true
run: |
cd gl4es
git config --global user.email "github-actions@users.noreply.github.com"
git config --global user.name "github-actions"
git remote add upstream https://github.com/PojavLauncherTeam/gl4es
git fetch upstream
git checkout master
git merge --allow-unrelated-histories upstream/master || echo "Merge exit code $?"
$ANDROID_NDK_HOME/ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk
cp -R libs/* ../app_pojavlauncher/src/main/jniLibs/
- name: Install gl4es
if: github.ref == 'refs/heads/v3_openjdk' && steps.gl4es-cache.outputs.cache-hit != 'true'
- name: Push gl4es
if: github.event != 'pull_request' && steps.gl4es-cache.outputs.cache-hit != 'true'
continue-on-error: true
run: |
cp -R gl4es/libs/* app_pojavlauncher/src/main/jniLibs/
mv gl4es ..
git add .
git commit -am "CI: Update gl4es"
git push
- name: Get vgpu latest commit hash
if: github.ref == 'refs/heads/v3_openjdk'
id: vgpu-sha
run: echo "::set-output name=sha::$(echo $(git ls-remote https://github.com/PojavLauncherTeam/VGPU refs/heads/main | grep -io '^\S*'))"
shell: bash
- name: Cache vgpu
if: github.ref == 'refs/heads/v3_openjdk'
uses: actions/cache@v2
id: vgpu-cache
with:
path: vgpu/libs
key: vgpu-android-shared-1-${{ steps.vgpu-sha.outputs.sha }}
- name: Get vgpu
if: github.ref == 'refs/heads/v3_openjdk' && steps.vgpu-cache.outputs.cache-hit != 'true'
uses: actions/checkout@v2
with:
repository: 'PojavLauncherTeam/VGPU'
path: 'vgpu'
- name: Build vgpu
if: github.ref == 'refs/heads/v3_openjdk' && steps.vgpu-cache.outputs.cache-hit != 'true'
continue-on-error: true
run: |
cd vgpu
$ANDROID_NDK_HOME/ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk
- name: Install vgpu
if: github.ref == 'refs/heads/v3_openjdk' && steps.vgpu-cache.outputs.cache-hit != 'true'
run: |
cp -R vgpu/libs/* app_pojavlauncher/src/main/jniLibs/
mv vgpu ..
git config --global user.email "github-actions@users.noreply.github.com"
git config --global user.name "github-actions"
git add .
git commit -am "CI: Update vgpu"
git push
- name: Get JRE8
uses: dawidd6/action-download-artifact@v2
with:
@ -118,8 +72,9 @@ jobs:
branch: buildjre8
name: jre8-pojav
- name: Build APK with Gradle
- name: Build JRE JAR files
run: |
cp -R gl4es/libs/* app_pojavlauncher/src/main/jniLibs/
chmod +x scripts/languagelist_updater.sh
bash scripts/languagelist_updater.sh
@ -129,25 +84,32 @@ jobs:
# Build JRE JAR files (security manager, etc...)
./gradlew :jre_lwjgl3glfw:build
- name: Build Google Play .aab
if: github.repository_owner == 'PojavLauncherTeam' && github.ref_name == 'v3_openjdk'
run: |
./gradlew :app_pojavlauncher:bundleGplay
mv app_pojavlauncher/build/outputs/bundle/gplay/app_pojavlauncher-gplay.aab out/app-gplay.aab
- name: Build Debug .apk
run: |
# Build the launcher
./gradlew :app_pojavlauncher:assembleDebug
mv app_pojavlauncher/build/outputs/apk/debug/app_pojavlauncher-debug.apk out/app-debug.apk
# mv app_pojavlauncher/build/intermediates/merged_native_libs/debug/out/lib out/debug_lib
- name: Build APK without runtime
run: |
rm -r app_pojavlauncher/src/main/assets/components/jre
./gradlew assembleDebug
mv app_pojavlauncher/build/outputs/apk/debug/app_pojavlauncher-debug.apk out/app-debug-noruntime.apk
- name: Upload APK
uses: actions/upload-artifact@v2
with:
name: app-debug
path: out/app-debug.apk
- name: Upload onto the Google Play testing track
if: github.ref == 'refs/heads/v3_openjdk'
if: github.repository_owner == 'PojavLauncherTeam' && github.ref_name == 'v3_openjdk'
uses: r0adkll/upload-google-play@v1.0.15
with:
serviceAccountJsonPlainText: ${{ secrets.GPLAY_SERVICE_JSON }}
@ -155,6 +117,7 @@ jobs:
releaseFiles: out/app-gplay.aab
track: internal
inAppUpdatePriority: 5
- name: Upload APK (without runtime)
uses: actions/upload-artifact@v2
with:

View file

@ -399,6 +399,7 @@ public class PojavLoginActivity extends BaseActivity {
}
}
}
private void migrateToProfiles() {
try {
if(!PerVersionConfig.exists()) return;
@ -407,16 +408,24 @@ public class PojavLoginActivity extends BaseActivity {
if(PerVersionConfig.erase()) {
for (String version : PerVersionConfig.configMap.keySet()) {
PerVersionConfig.VersionConfig config = PerVersionConfig.configMap.get(version);
if (config != null) {
MinecraftProfile profile = new MinecraftProfile();
profile.lastVersionId = version;
profile.name = getString(R.string.migrated_profile_str, version);
profile.pojavRendererName = config.renderer;
profile.gameDir = config.gamePath;
profile.javaDir = Tools.LAUNCHERPROFILES_RTPREFIX + config.selectedRuntime;
profile.javaArgs = config.jvmArgs;
LauncherProfiles.mainProfileJson.profiles.put("pvc-migrated-" + version, profile);
if(config == null) continue; // Skip the version
// Replaced by gl4es_extra
if(config.renderer.contains("zink")) config.renderer = "opengles3_virgl";
if(!config.renderer.contains("virgl")) config.renderer = null;
if(config.renderer == null && config.gamePath == null &&
config.jvmArgs == null && config.selectedRuntime == null){
continue; // Empty pvc, skip it.
}
MinecraftProfile profile = new MinecraftProfile();
profile.lastVersionId = version;
profile.name = getString(R.string.migrated_profile_str, version);
profile.pojavRendererName = config.renderer;
profile.gameDir = config.gamePath;
profile.javaDir = Tools.LAUNCHERPROFILES_RTPREFIX + config.selectedRuntime;
profile.javaArgs = config.jvmArgs;
LauncherProfiles.mainProfileJson.profiles.put("pvc-migrated-" + version, profile);
}
LauncherProfiles.update();
}else{
@ -426,6 +435,7 @@ public class PojavLoginActivity extends BaseActivity {
Log.e("ProfileMigrator","Failed to migrate!",e);
}
}
private boolean installRuntimeAutomatically(AssetManager am, boolean otherRuntimesAvailable) {
/* Check if JRE is included */
String rt_version = null;

View file

@ -38,6 +38,10 @@ import static android.os.Build.VERSION_CODES.Q;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_IGNORE_NOTCH;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_NOTCH_SIZE;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.core.view.WindowInsetsControllerCompat;
public final class Tools {
public static final boolean ENABLE_DEV_FEATURES = BuildConfig.DEBUG;
@ -132,6 +136,9 @@ public final class Tools {
PojavLoginActivity.disableSplash(gamedirPath);
String[] launchArgs = getMinecraftArgs(profile, versionInfo, gamedirPath);
// Select the appropriate openGL version
OldVersionsUtils.selectOpenGlVersion(versionInfo);
// ctx.appendlnToLog("Minecraft Args: " + Arrays.toString(launchArgs));
String launchClassPath = generateLaunchClassPath(versionInfo,versionName);
@ -356,8 +363,7 @@ public final class Tools {
public static DisplayMetrics getDisplayMetrics(Activity activity) {
DisplayMetrics displayMetrics = new DisplayMetrics();
if(SDK_INT >= Build.VERSION_CODES.N && (activity.isInMultiWindowMode() || activity.isInPictureInPictureMode())
|| PREF_NOTCH_SIZE == -1 ){
if(SDK_INT >= Build.VERSION_CODES.N && (activity.isInMultiWindowMode() || activity.isInPictureInPictureMode())){
//For devices with free form/split screen, we need window size, not screen size.
displayMetrics = activity.getResources().getDisplayMetrics();
}else{
@ -376,21 +382,18 @@ public final class Tools {
return displayMetrics;
}
public static void setFullscreen(Activity act) {
final View decorView = act.getWindow().getDecorView();
decorView.setOnSystemUiVisibilityChangeListener (new View.OnSystemUiVisibilityChangeListener() {
@Override
public void onSystemUiVisibilityChange(int visibility) {
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
}
});
public static void setFullscreen(Activity activity) {
final View decorView = activity.getWindow().getDecorView();
decorView.setOnSystemUiVisibilityChangeListener (visibility -> {
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
});
}
public static DisplayMetrics currentDisplayMetrics;

View file

@ -5,6 +5,8 @@ public class ExtraConstants {
public static final String RELEASE_TABLE = "release_table";
/* ExtraCore constant: an ArrayList of Strings, where each String is a Minecraft version name */
public static final String VERSION_LIST= "lac_version_list";
/* ExraCore constant: Serpent's back button tracking thing */
/* ExtraCore constant: Serpent's back button tracking thing */
public static final String BACK_PREFERENCE = "back_preference";
/* ExtraCore constant: The OPENGL version that should be exposed */
public static final String OPEN_GL_VERSION = "open_gl_version";
}

View file

@ -33,10 +33,7 @@ public class LauncherPreferences {
public static int PREF_CONTROL_BOTTOM_OFFSET = 0;
public static int PREF_CONTROL_LEFT_OFFSET = 0;
public static boolean PREF_SUSTAINED_PERFORMANCE = false;
public static String PREF_GLES_SHRINK_HACK = "0";
public static boolean PREF_VBO_DISABLE_HACK = false;
public static boolean PREF_VIRTUAL_MOUSE_START = false;
public static boolean PREF_OPENGL_VERSION_HACK = false;
public static boolean PREF_ARC_CAPES = false;
public static boolean PREF_USE_ALTERNATE_SURFACE = true;
public static int PREF_SCALE_FACTOR = 100;
@ -69,10 +66,7 @@ public class LauncherPreferences {
PREF_CONTROL_BOTTOM_OFFSET = DEFAULT_PREF.getInt("controlBottomOffset", 0);
PREF_CONTROL_LEFT_OFFSET = DEFAULT_PREF.getInt("controlLeftOffset", 0);
PREF_SUSTAINED_PERFORMANCE = DEFAULT_PREF.getBoolean("sustainedPerformance", false);
PREF_GLES_SHRINK_HACK = DEFAULT_PREF.getString("gl4es_shrink_hack", "0");
PREF_VBO_DISABLE_HACK = DEFAULT_PREF.getBoolean("vbo_disable_hack", false);
PREF_VIRTUAL_MOUSE_START = DEFAULT_PREF.getBoolean("mouse_start", false);
PREF_OPENGL_VERSION_HACK = DEFAULT_PREF.getBoolean("gles_version_hack", false);
PREF_ARC_CAPES = DEFAULT_PREF.getBoolean("arc_capes",false);
PREF_USE_ALTERNATE_SURFACE = DEFAULT_PREF.getBoolean("alternate_surface", false);
PREF_SCALE_FACTOR = DEFAULT_PREF.getInt("resolutionRatio", 100);
@ -105,9 +99,6 @@ public class LauncherPreferences {
}
*/
if (PREF_RENDERER.equals("2") || PREF_RENDERER.equals("3")) {
PREF_RENDERER = "opengles" + PREF_RENDERER;
}
String argLwjglLibname = "-Dorg.lwjgl.opengl.libname=";
for (String arg : JREUtils.parseJavaArguments(PREF_CUSTOM_JAVA_ARGS)) {
if (arg.startsWith(argLwjglLibname)) {

View file

@ -19,7 +19,7 @@ public class LauncherPreferenceVideoFragment extends LauncherPreferenceFragment
addPreferencesFromResource(R.xml.pref_video);
//Disable notch checking behavior on android 8.1 and below.
findPreference("ignoreNotch").setVisible(Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && PREF_NOTCH_SIZE != 0);
findPreference("ignoreNotch").setVisible(Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && PREF_NOTCH_SIZE > 0);
CustomSeekBarPreference seek5 = findPreference("resolutionRatio");
seek5.setMin(25);

View file

@ -38,114 +38,119 @@ import java.util.Map;
import java.util.UUID;
public class ProfileEditor implements ExtraListener<ArrayList<String>> {
private final View mainView;
private final TextView profileNameView;
private final ImageView profileIconView;
private final Spinner versionSpinner;
private final Spinner javaRuntimeSpinner;
private final Spinner rendererSpinner;
private final EditText pathSelectionEditor;
private final List<String> renderNames;
private final AlertDialog dialog;
private String selectedVersionId;
private String editingProfile;
private final EditSaveCallback editSaveCallback;
private final Handler uiThreadHandler;
private final View mMainView;
private final TextView mProfileNameTextView;
private final ImageView mProfileIconImageView;
private final Spinner mVersionSpinner;
private final Spinner mJavaRuntimeSpinner;
private final Spinner mRendererSpinner;
private final EditText mPathSelectionEditText;
private final List<String> mRenderNames;
private final AlertDialog mDialog;
private String mSelectedVersionId;
private String mEditingProfile;
private final EditSaveCallback mEditSaveCallback;
private final Handler mUiThreadHandler;
public static MinecraftProfile generateTemplate() {
MinecraftProfile TEMPLATE = new MinecraftProfile();
TEMPLATE.name = "New";
TEMPLATE.lastVersionId = "latest-release";
return TEMPLATE;
}
public ProfileEditor(Context _ctx, EditSaveCallback editSaveCallback) {
this.editSaveCallback = editSaveCallback;
uiThreadHandler = new Handler(Looper.getMainLooper());
LayoutInflater inflater = LayoutInflater.from(_ctx);
mainView = inflater.inflate(R.layout.version_profile_editor,null);
AlertDialog.Builder builder = new AlertDialog.Builder(_ctx);
builder.setView(mainView);
profileNameView = mainView.findViewById(R.id.vprof_editior_profile_name);
versionSpinner = mainView.findViewById(R.id.vprof_editor_version_spinner);
javaRuntimeSpinner = mainView.findViewById(R.id.vprof_editor_spinner_runtime);
rendererSpinner = mainView.findViewById(R.id.vprof_editor_profile_renderer);
public ProfileEditor(Context ctx, EditSaveCallback editSaveCallback) {
this.mEditSaveCallback = editSaveCallback;
mUiThreadHandler = new Handler(Looper.getMainLooper());
LayoutInflater inflater = LayoutInflater.from(ctx);
mMainView = inflater.inflate(R.layout.version_profile_editor,null);
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
builder.setView(mMainView);
mProfileNameTextView = mMainView.findViewById(R.id.vprof_editior_profile_name);
mVersionSpinner = mMainView.findViewById(R.id.vprof_editor_version_spinner);
mJavaRuntimeSpinner = mMainView.findViewById(R.id.vprof_editor_spinner_runtime);
mRendererSpinner = mMainView.findViewById(R.id.vprof_editor_profile_renderer);
{
Context context = rendererSpinner.getContext();
Context context = mRendererSpinner.getContext();
List<String> renderList = new ArrayList<>();
Collections.addAll(renderList, context.getResources().getStringArray(R.array.renderer));
renderList.add("Default");
renderNames = Arrays.asList(context.getResources().getStringArray(R.array.renderer_values));
rendererSpinner.setAdapter(new ArrayAdapter<>(context, android.R.layout.simple_spinner_dropdown_item,renderList));
mRenderNames = Arrays.asList(context.getResources().getStringArray(R.array.renderer_values));
mRendererSpinner.setAdapter(new ArrayAdapter<>(context, android.R.layout.simple_spinner_dropdown_item,renderList));
}
profileIconView = mainView.findViewById(R.id.vprof_editor_icon);
((TextView)mainView.findViewById(R.id.vprof_editor_beginPathView)).setText(Tools.DIR_GAME_HOME+"/");
pathSelectionEditor = mainView.findViewById(R.id.vprof_editor_path);
mProfileIconImageView = mMainView.findViewById(R.id.vprof_editor_icon);
((TextView)mMainView.findViewById(R.id.vprof_editor_beginPathView)).setText(Tools.DIR_GAME_HOME+"/");
mPathSelectionEditText = mainView.findViewById(R.id.vprof_editor_path);
builder.setPositiveButton(R.string.global_save,this::save);
builder.setNegativeButton(android.R.string.cancel,(dialog,which)->destroy(dialog));
builder.setNeutralButton(R.string.global_delete,(dialogInterface, i) -> {
LauncherProfiles.mainProfileJson.profiles.remove(editingProfile);
this.editSaveCallback.onSave(editingProfile,false, true);
LauncherProfiles.mainProfileJson.profiles.remove(mEditingProfile);
this.mEditSaveCallback.onSave(mEditingProfile,false, true);
});
builder.setOnDismissListener(this::destroy);
dialog = builder.create();
mDialog = builder.create();
}
public boolean show(@NonNull String profile) {
MinecraftProfile minecraftProfile;
if(!ProfileAdapter.CREATE_PROFILE_MAGIC.equals(profile)) {
minecraftProfile = LauncherProfiles.mainProfileJson.profiles.get(profile);
if (minecraftProfile == null) return true;
editingProfile = profile;
mEditingProfile = profile;
}else{
minecraftProfile = generateTemplate();
String uuid = UUID.randomUUID().toString();
while(LauncherProfiles.mainProfileJson.profiles.containsKey(uuid)) {
uuid = UUID.randomUUID().toString();
}
editingProfile = uuid;
mEditingProfile = uuid;
}
List<Runtime> runtimes = MultiRTUtils.getRuntimes();
Context context = javaRuntimeSpinner.getContext();
javaRuntimeSpinner.setAdapter(new RTSpinnerAdapter(context, runtimes));
Context context = mJavaRuntimeSpinner.getContext();
mJavaRuntimeSpinner.setAdapter(new RTSpinnerAdapter(context, runtimes));
int jvmIndex = runtimes.indexOf(new Runtime("<Default>"));
int rendererIndex = rendererSpinner.getAdapter().getCount()-1;
int rendererIndex = mRendererSpinner.getAdapter().getCount()-1;
if (minecraftProfile.javaDir != null) {
String selectedRuntime = minecraftProfile.javaDir.substring(Tools.LAUNCHERPROFILES_RTPREFIX.length());
int nindex = runtimes.indexOf(new Runtime(selectedRuntime));
if (nindex != -1) jvmIndex = nindex;
}
if(minecraftProfile.pojavRendererName != null) {
int nindex = renderNames.indexOf(minecraftProfile.pojavRendererName);
int nindex = mRenderNames.indexOf(minecraftProfile.pojavRendererName);
if(nindex != -1) rendererIndex = nindex;
}
javaRuntimeSpinner.setSelection(jvmIndex);
rendererSpinner.setSelection(rendererIndex);
mJavaRuntimeSpinner.setSelection(jvmIndex);
mRendererSpinner.setSelection(rendererIndex);
ExtraCore.addExtraListener(ExtraConstants.VERSION_LIST,this);
profileNameView.setText(minecraftProfile.name);
mProfileNameTextView.setText(minecraftProfile.name);
Bitmap profileIcon = ProfileIconCache.getCachedIcon(profile);
if(profileIcon == null) {
profileIcon = ProfileIconCache.tryResolveIcon(profile,minecraftProfile.icon);
}
profileIconView.setImageBitmap(profileIcon);
mProfileIconImageView.setImageBitmap(profileIcon);
if(minecraftProfile.lastVersionId != null && !"latest-release".equals(minecraftProfile.lastVersionId) && !"latest-snapshot".equals(minecraftProfile.lastVersionId))
selectedVersionId = minecraftProfile.lastVersionId;
mSelectedVersionId = minecraftProfile.lastVersionId;
else if(minecraftProfile.lastVersionId != null) {
Map<String,String> releaseTable = (Map<String,String>)ExtraCore.getValue(ExtraConstants.RELEASE_TABLE);
if(releaseTable != null) {
switch (minecraftProfile.lastVersionId) {
case "latest-release":
selectedVersionId = releaseTable.get("release");
mSelectedVersionId = releaseTable.get("release");
case "latest-snapshot":
selectedVersionId = releaseTable.get("snapshot");
mSelectedVersionId = releaseTable.get("snapshot");
}
}else{
selectedVersionId = null;
mSelectedVersionId = null;
}
}
else{
if(PojavLauncherActivity.basicVersionList.length > 0) {
selectedVersionId = PojavLauncherActivity.basicVersionList[0];
mSelectedVersionId = PojavLauncherActivity.basicVersionList[0];
}
}
ArrayList<String> versions = (ArrayList<String>) ExtraCore.getValue(ExtraConstants.VERSION_LIST);
BaseLauncherActivity.updateVersionSpinner(context,versions,versionSpinner, selectedVersionId);
if(minecraftProfile.gameDir != null && minecraftProfile.gameDir.startsWith(Tools.LAUNCHERPROFILES_RTPREFIX)) {
pathSelectionEditor.setText(minecraftProfile.gameDir.substring(Tools.LAUNCHERPROFILES_RTPREFIX.length()));
@ -154,25 +159,25 @@ public class ProfileEditor implements ExtraListener<ArrayList<String>> {
return true;
}
public void save(DialogInterface dialog, int which) {
System.out.println(editingProfile);
System.out.println(mEditingProfile);
MinecraftProfile profile;
boolean isNew;
if(LauncherProfiles.mainProfileJson.profiles.containsKey(editingProfile)) {
profile = LauncherProfiles.mainProfileJson.profiles.get(editingProfile);
if(LauncherProfiles.mainProfileJson.profiles.containsKey(mEditingProfile)) {
profile = LauncherProfiles.mainProfileJson.profiles.get(mEditingProfile);
if(profile == null) {
profile = new MinecraftProfile();
isNew = true;
}else{
isNew = false;
}
LauncherProfiles.mainProfileJson.profiles.remove(editingProfile);
LauncherProfiles.mainProfileJson.profiles.remove(mEditingProfile);
}else{
profile = new MinecraftProfile();
isNew = true;
}
profile.name = profileNameView.getText().toString();
profile.lastVersionId = (String)versionSpinner.getSelectedItem();
Runtime selectedRuntime = (Runtime) javaRuntimeSpinner.getSelectedItem();
profile.name = mProfileNameTextView.getText().toString();
profile.lastVersionId = (String) mVersionSpinner.getSelectedItem();
Runtime selectedRuntime = (Runtime) mJavaRuntimeSpinner.getSelectedItem();
if(selectedRuntime.name.equals("<Default>")) {
profile.javaDir = null;
}else if(selectedRuntime.versionString == null) {
@ -180,25 +185,26 @@ public class ProfileEditor implements ExtraListener<ArrayList<String>> {
}else{
profile.javaDir = Tools.LAUNCHERPROFILES_RTPREFIX+selectedRuntime.name;
}
if(rendererSpinner.getSelectedItemPosition() == renderNames.size()) profile.pojavRendererName = null;
else profile.pojavRendererName = renderNames.get(rendererSpinner.getSelectedItemPosition());
String selectedPath = pathSelectionEditor.getText().toString();
if(mRendererSpinner.getSelectedItemPosition() == mRenderNames.size()) profile.pojavRendererName = null;
else profile.pojavRendererName = mRenderNames.get(mRendererSpinner.getSelectedItemPosition());
String selectedPath = mPathSelectionEditText.getText().toString();
if(!selectedPath.isEmpty()) {
profile.gameDir = Tools.LAUNCHERPROFILES_RTPREFIX+selectedPath;
}
LauncherProfiles.mainProfileJson.profiles.put(editingProfile,profile);
editSaveCallback.onSave(editingProfile,isNew, false);
LauncherProfiles.mainProfileJson.profiles.put(mEditingProfile,profile);
mEditSaveCallback.onSave(mEditingProfile,isNew, false);
destroy(dialog);
}
public void destroy(@NonNull DialogInterface dialog) {
ExtraCore.removeExtraListenerFromValue(ExtraConstants.VERSION_LIST,this);
editingProfile = null;
selectedVersionId = null;
mEditingProfile = null;
mSelectedVersionId = null;
}
@Override
public boolean onValueSet(String key, @Nullable ArrayList<String> value) {
if(value != null) {
uiThreadHandler.post(() -> BaseLauncherActivity.updateVersionSpinner(mainView.getContext(), value, versionSpinner, selectedVersionId));
mUiThreadHandler.post(() -> BaseLauncherActivity.updateVersionSpinner(mMainView.getContext(), value, mVersionSpinner, mSelectedVersionId));
}
return false;
}

View file

@ -13,28 +13,28 @@ import java.util.Map;
public class ProfileIconCache {
private static final String BASE64_PNG_HEADER = "data:image/png;base64,";
private static final Map<String, Bitmap> iconCache = new HashMap<>();
private static Bitmap defaultIcon;
private static final Map<String, Bitmap> sIconCache = new HashMap<>();
private static Bitmap sDefaultIcon;
public static void initDefault(Context context) {
if(defaultIcon == null)
defaultIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_menu_java);
if(sDefaultIcon == null)
sDefaultIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_menu_java);
}
public static void clearIconCache() {
for(String key : iconCache.keySet()) {
Bitmap bitmap = iconCache.get(key);
if(bitmap != defaultIcon && bitmap != null) {
for(String key : sIconCache.keySet()) {
Bitmap bitmap = sIconCache.get(key);
if(bitmap != sDefaultIcon && bitmap != null) {
bitmap.recycle();
}
}
iconCache.clear();
sIconCache.clear();
}
public static Bitmap getCachedIcon(String key) {
return iconCache.get(key);
return sIconCache.get(key);
}
public static Bitmap submitIcon(String key, String base64) {
byte[] pngBytes = Base64.decode(base64, Base64.DEFAULT);
Bitmap cachedIcon = BitmapFactory.decodeByteArray(pngBytes,0,pngBytes.length);
iconCache.put(key, cachedIcon);
sIconCache.put(key, cachedIcon);
return cachedIcon;
}
public static Bitmap tryResolveIcon(String profileName, String b64Icon) {
@ -48,7 +48,7 @@ public class ProfileIconCache {
return icon;
}
public static Bitmap pushDefaultIcon(String key) {
iconCache.put(key, defaultIcon);
return defaultIcon;
sIconCache.put(key, sDefaultIcon);
return sDefaultIcon;
}
}

View file

@ -4,10 +4,6 @@ import static net.kdt.pojavlaunch.Architecture.ARCH_X86;
import static net.kdt.pojavlaunch.Architecture.is64BitsDevice;
import static net.kdt.pojavlaunch.Tools.LOCAL_RENDERER;
import static net.kdt.pojavlaunch.Tools.currentDisplayMetrics;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_BUTTONSIZE;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_GLES_SHRINK_HACK;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_OPENGL_VERSION_HACK;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_VBO_DISABLE_HACK;
import android.app.*;
import android.content.*;
@ -20,6 +16,8 @@ import com.oracle.dalvik.*;
import java.io.*;
import java.util.*;
import net.kdt.pojavlaunch.*;
import net.kdt.pojavlaunch.extra.ExtraConstants;
import net.kdt.pojavlaunch.extra.ExtraCore;
import net.kdt.pojavlaunch.prefs.*;
import org.lwjgl.glfw.*;
@ -199,17 +197,11 @@ public class JREUtils {
// On certain GLES drivers, overloading default functions shader hack fails, so disable it
envMap.put("LIBGL_NOINTOVLHACK", "1");
// The shrink hack can be enabled from the experimental settings
envMap.put("LIBGL_SHRINK", PREF_GLES_SHRINK_HACK);
// VBO disable hack
if (PREF_VBO_DISABLE_HACK) envMap.put("LIBGL_USEVBO","0");
// openGL version hack
if (PREF_OPENGL_VERSION_HACK) envMap.put("LIBGL_ES", "1");
// Fix white color on banner and sheep, since GL4ES 1.1.5
envMap.put("LIBGL_NORMALIZE", "1");
// The OPEN GL version is changed according
envMap.put("LIBGL_ES", (String) ExtraCore.getValue(ExtraConstants.OPEN_GL_VERSION));
envMap.put("MESA_GLSL_CACHE_DIR", activity.getCacheDir().getAbsolutePath());
if (LOCAL_RENDERER != null) {
@ -262,7 +254,11 @@ public class JREUtils {
}
for (Map.Entry<String, String> env : envMap.entrySet()) {
Logger.getInstance().appendToLog("Added custom env: " + env.getKey() + "=" + env.getValue());
Os.setenv(env.getKey(), env.getValue(), true);
try {
Os.setenv(env.getKey(), env.getValue(), true);
}catch (NullPointerException exception){
Log.e("JREUtils", exception.toString());
}
}
File serverFile = new File(Tools.DIR_HOME_JRE + "/" + Tools.DIRNAME_HOME_JRE + "/server/libjvm.so");
@ -438,11 +434,8 @@ public class JREUtils {
String renderLibrary;
switch (LOCAL_RENDERER){
case "opengles2": renderLibrary = "libgl4es_114.so"; break;
case "opengles2_5":
case "opengles3": renderLibrary = "libgl4es_115.so"; break;
case "opengles3_virgl":
case "vulkan_zink": renderLibrary = "libOSMesa_8.so"; break;
case "opengles3_vgpu" : renderLibrary = "libvgpu.so"; break;
default:
Log.w("RENDER_LIBRARY", "No renderer selected, defaulting to opengles2");
renderLibrary = "libgl4es_114.so";
@ -487,7 +480,8 @@ public class JREUtils {
}
return false;
}
private static int getDetectedVersion() {
public static int getDetectedVersion() {
/*
* Get all the device configurations and check the EGL_RENDERABLE_TYPE attribute
* to determine the highest ES version supported by any config. The

View file

@ -0,0 +1,36 @@
package net.kdt.pojavlaunch.utils;
import android.util.Log;
import net.kdt.pojavlaunch.JMinecraftVersionList;
import net.kdt.pojavlaunch.extra.ExtraConstants;
import net.kdt.pojavlaunch.extra.ExtraCore;
import net.kdt.pojavlaunch.value.launcherprofiles.MinecraftProfile;
import java.sql.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Locale;
/** Class here to help with various stuff to help run lower versions smoothly */
public class OldVersionsUtils {
/** Lower minecraft versions fare better with opengl 1
* @param version The version about to be launched
*/
public static void selectOpenGlVersion(JMinecraftVersionList.Version version){
// 1309989600 is 2011-07-07 2011-07-07T22:00:00+00:00
String creationDate = version.time;
if(creationDate == null || creationDate.isEmpty()){
ExtraCore.setValue(ExtraConstants.OPEN_GL_VERSION, "2");
return;
}
try {
String openGlVersion = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH).parse(creationDate.substring(0, creationDate.indexOf("T"))).before(new Date(2011-1900, 6, 7)) ? "1" : "2";
ExtraCore.setValue(ExtraConstants.OPEN_GL_VERSION, openGlVersion);
}catch (ParseException exception){
Log.e("OPENGL SELECTION", exception.toString());
ExtraCore.setValue(ExtraConstants.OPEN_GL_VERSION, "2");
}
}
}

View file

@ -104,7 +104,7 @@ public class V117CompatUtil {
return ret.toString();
}
public static void runCheck(String version, Activity ctx) throws Exception{
public static void runCheck(String version, Activity activity) throws Exception{
MCOptionUtils.load();
@ -112,35 +112,34 @@ public class V117CompatUtil {
List<String> packList =getTexturePackList(MCOptionUtils.get("resourcePacks"));
String renderer;
String gamePath;
LauncherProfiles.update();
MinecraftProfile prof = LauncherProfiles.mainProfileJson.profiles.get(((BaseLauncherActivity)ctx).mProfile.selectedProfile);
if(prof == null) throw new MinecraftDownloaderTask.SilentException();
renderer = prof.pojavRendererName != null?prof.pojavRendererName :LauncherPreferences.PREF_RENDERER;
gamePath = prof.gameDir != null && prof.gameDir.startsWith(Tools.LAUNCHERPROFILES_RTPREFIX)?prof.gameDir.replace(Tools.LAUNCHERPROFILES_RTPREFIX,Tools.DIR_GAME_HOME+"/"):Tools.DIR_GAME_NEW;
LauncherProfiles.update();
MinecraftProfile prof = LauncherProfiles.mainProfileJson.profiles.get(((BaseLauncherActivity)ctx).mProfile.selectedProfile);
if(prof == null) throw new MinecraftDownloaderTask.SilentException();
renderer = prof.pojavRendererName != null ? prof.pojavRendererName : LauncherPreferences.PREF_RENDERER;
gamePath = prof.gameDir != null && prof.gameDir.startsWith(Tools.LAUNCHERPROFILES_RTPREFIX) ? prof.gameDir.replace(Tools.LAUNCHERPROFILES_RTPREFIX,Tools.DIR_GAME_HOME + "/") : 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;
if(packList.contains("\"assets-v0.zip\"")) return;
if(JREUtils.getDetectedVersion() >= 3) return; // GL4ES_extra supports 1.17+
Object lock = new Object();
AtomicInteger proceed = new AtomicInteger(0);
ctx.runOnUiThread(() -> {
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
activity.runOnUiThread(() -> {
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(R.string.global_warinng);
builder.setMessage(R.string.compat_117_message);
builder.setPositiveButton(android.R.string.ok, (dialog, which) -> {
proceed.set(1);
synchronized (lock) { lock.notifyAll(); }
dialog.dismiss();
});
builder.setNegativeButton(android.R.string.cancel, (dialog, which) -> {
synchronized (lock) { lock.notifyAll(); }
dialog.dismiss();
});
builder.setNeutralButton(R.string.compat_11x_playanyway, (dialog, which) -> {
proceed.set(2);
synchronized (lock) { lock.notifyAll(); }
dialog.dismiss();
});
builder.setCancelable(false);
builder.show();
@ -151,11 +150,11 @@ public class V117CompatUtil {
}
switch(proceed.get()) {
case 1:
MinecraftProfile minecraftProfile = LauncherProfiles.mainProfileJson.profiles.get(((BaseLauncherActivity)ctx).mProfile.selectedProfile);
if(minecraftProfile == null) throw new MinecraftDownloaderTask.SilentException();
minecraftProfile.pojavRendererName = "opengles3";
LauncherProfiles.update();
copyResourcePack(gamePath,ctx.getAssets());
MinecraftProfile minecraftProfile = LauncherProfiles.mainProfileJson.profiles.get(((BaseLauncherActivity)activity).mProfile.selectedProfile);
if(minecraftProfile == null) throw new MinecraftDownloaderTask.SilentException();
minecraftProfile.pojavRendererName = "opengles2";
LauncherProfiles.update();
copyResourcePack(gamePath,activity.getAssets());
if(!packList.contains("\"assets-v0.zip\"")) packList.add(0,"\"assets-v0.zip\"");
MCOptionUtils.set("resourcePacks",regenPackList(packList));
MCOptionUtils.save();

Binary file not shown.

View file

@ -2,19 +2,13 @@
<resources>
<string-array name="renderer">
<item name="2">@string/mcl_setting_renderer_gles2_4</item>
<item name="3">@string/mcl_setting_renderer_gles2_5</item>
<item name="3">@string/mcl_setting_renderer_gles3_5</item>
<!-- <item name="4">@string/mcl_setting_renderer_vulkan_zink</item> -->
<item name="5">@string/mcl_setting_renderer_vgpu</item>
<item name="5">@string/mcl_setting_renderer_virgl</item>
</string-array>
<string-array name="renderer_values">
<item>opengles2</item> <!-- gl4es 1.1.4 with OpenGL ES 2 -->
<item>opengles2_5</item> <!-- gl4es 1.1.5 with OpenGL ES 2 -->
<item>opengles3</item> <!-- gl4es 1.1.5 with OpenGL ES 3 -->
<item>opengles2</item> <!-- gl4es_extra 1.1.4 with OpenGL ES 2/"3" -->
<!--<item>vulkan_zink</item> -->
<item>opengles3_vgpu</item> <!-- vgpu with OpenGL ES 3 -->
<item>opengles3_virgl</item> <!-- virglrenderer with OpenGL ES 3 -->
</string-array>

View file

@ -101,8 +101,6 @@
<string name="mcl_setting_category_scaling">Scaling settings</string>
<string name="mcl_setting_category_renderer">Renderer</string>
<string name="mcl_setting_renderer_gles2_4">gl4es 1.1.4 (OpenGL ES 2): exports OpenGL 2.1</string>
<string name="mcl_setting_renderer_gles2_5">gl4es 1.1.5 (OpenGL ES 2): exports OpenGL 2.1</string>
<string name="mcl_setting_renderer_gles3_5">gl4es 1.1.5 (OpenGL ES 3): exports OpenGL 2.1 + partial 3.2</string>
<string name="mcl_setting_renderer_virgl">virglrenderer (OpenGL ES 3): exports OpenGL 4.3</string>
<string name="mcl_setting_renderer_vgpu">vgpu (OpenGL ES 3): exports OpenGL 3.0</string>
<string name="mcl_setting_renderer_vulkan_zink">zink (Vulkan): exports OpenGL 4.6</string>
@ -293,15 +291,9 @@
<string name="profiles_editing">Editing profile</string>
<string name="profiles_profile_name">Name</string>
<string name="profiles_profile_version">Version</string>
<string name="option_enable_profiles">Profiles</string>
<string name="option_enable_profiles_descritption">Use Minecraft Launcher profiles instead of the regular version list. Supports icons!</string>
<string name="vbo_hack_title">Disable VBOs</string>
<string name="vbo_hack_description">Help with compatibility on some old versions</string>
<string name="global_delete">Delete</string>
<string name="pedit_java_runtime">Java Runtime</string>
<string name="pedit_renderer">Renderer</string>
<string name="gles_version_hack_title">Force openGL 1</string>
<string name="gles_version_hack_description">Help with compatibility on some old versions</string>
<string name="arc_capes_title">Arc Capes</string>
<string name="arc_capes_desc">Enables capes from Arc. For more information please visit https://arccapes.com. Requires OptiFine.</string>
<string name="migrated_profile_str">%s version configuration</string>

View file

@ -12,24 +12,5 @@
android:entries="@array/hack_gles_shrink"
app2:useSimpleSummaryProvider="true"/>
<SwitchPreference
android:title="@string/vbo_hack_title"
android:summary="@string/vbo_hack_description"
android:defaultValue="false"
android:key="vbo_disable_hack"
/>
<CheckBoxPreference
android:defaultValue="false"
android:key="enable_profiles"
android:title="@string/option_enable_profiles"
android:summary="@string/option_enable_profiles_descritption"/>
<SwitchPreference
android:title="@string/gles_version_hack_title"
android:summary="@string/gles_version_hack_description"
android:defaultValue="false"
android:key="gles_version_hack"
/>
</PreferenceCategory>
</PreferenceScreen>

2
gl4es

@ -1 +1 @@
Subproject commit baf1c7482ee8dd138324a1f670fc04706723ed83
Subproject commit ec8a3fbf4350dfae12646668bf379fd6164f91db