diff --git a/app_pojavlauncher/src/main/assets/components/lwjgl3/lwjgl-glfw-classes.jar b/app_pojavlauncher/src/main/assets/components/lwjgl3/lwjgl-glfw-classes.jar index 04a1ed62b..5ac149831 100644 Binary files a/app_pojavlauncher/src/main/assets/components/lwjgl3/lwjgl-glfw-classes.jar and b/app_pojavlauncher/src/main/assets/components/lwjgl3/lwjgl-glfw-classes.jar differ diff --git a/app_pojavlauncher/src/main/assets/components/lwjgl3/version b/app_pojavlauncher/src/main/assets/components/lwjgl3/version index dbd01091b..052402241 100644 --- a/app_pojavlauncher/src/main/assets/components/lwjgl3/version +++ b/app_pojavlauncher/src/main/assets/components/lwjgl3/version @@ -1 +1 @@ -b35956195a536dfa5895ca6d40d13c718de4d7fa \ No newline at end of file +276e966873587ef19ddad2f320052b8c10ff7a77 \ No newline at end of file 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 a451d3a9b..1630d4514 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Tools.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Tools.java @@ -219,7 +219,7 @@ public final class Tools { * @param gameDir current game directory * @return whether sodium or a sodium-based mod is installed */ - private static boolean hasSodium(File gameDir) { + public static boolean hasSodium(File gameDir) { File modsDir = new File(gameDir, "mods"); File[] mods = modsDir.listFiles(file -> file.isFile() && file.getName().endsWith(".jar")); if(mods == null) return false; diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/fragments/MainMenuFragment.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/fragments/MainMenuFragment.java index ee59d87e4..07e24ddd8 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/fragments/MainMenuFragment.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/fragments/MainMenuFragment.java @@ -1,12 +1,16 @@ package net.kdt.pojavlaunch.fragments; +import static net.kdt.pojavlaunch.Tools.dialogOnUiThread; import static net.kdt.pojavlaunch.Tools.hasNoOnlineProfileDialog; import static net.kdt.pojavlaunch.Tools.hasOnlineProfile; import static net.kdt.pojavlaunch.Tools.openPath; import static net.kdt.pojavlaunch.Tools.shareLog; +import android.content.DialogInterface; import android.content.Intent; +import android.content.SharedPreferences; import android.os.Bundle; +import android.os.CountDownTimer; import android.view.View; import android.widget.Button; import android.widget.ImageButton; @@ -14,17 +18,20 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.Fragment; import com.kdt.mcgui.mcVersionSpinner; import net.kdt.pojavlaunch.CustomControlsActivity; +import net.kdt.pojavlaunch.PojavProfile; import net.kdt.pojavlaunch.R; import net.kdt.pojavlaunch.Tools; import net.kdt.pojavlaunch.extra.ExtraConstants; import net.kdt.pojavlaunch.extra.ExtraCore; import net.kdt.pojavlaunch.prefs.LauncherPreferences; import net.kdt.pojavlaunch.progresskeeper.ProgressKeeper; +import net.kdt.pojavlaunch.value.MinecraftAccount; import net.kdt.pojavlaunch.value.launcherprofiles.LauncherProfiles; import net.kdt.pojavlaunch.value.launcherprofiles.MinecraftProfile; @@ -64,7 +71,16 @@ public class MainMenuFragment extends Fragment { } else mInstallJarButton.setOnClickListener(v -> hasNoOnlineProfileDialog(requireActivity())); mEditProfileButton.setOnClickListener(v -> mVersionSpinner.openProfileEditor(requireActivity())); - mPlayButton.setOnClickListener(v -> ExtraCore.setValue(ExtraConstants.LAUNCH_GAME, true)); + mPlayButton.setOnClickListener(v -> { + MinecraftProfile minecraftProfile = LauncherProfiles.getCurrentProfile(); + File gameDir = Tools.getGameDirPath(minecraftProfile); + if (Tools.hasSodium(gameDir) && !(LauncherPreferences.DEFAULT_PREF.getBoolean("sodium_override", false))) { + Tools.dialogOnUiThread(requireActivity(), + R.string.sodium_warning_title, R.string.sodium_warning_message); + } else ExtraCore.setValue(ExtraConstants.LAUNCH_GAME, true); + + + }); mShareLogsButton.setOnClickListener((v) -> shareLog(requireContext())); diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/prefs/MathQuestionPreference.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/prefs/MathQuestionPreference.java new file mode 100644 index 000000000..187dd2bc4 --- /dev/null +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/prefs/MathQuestionPreference.java @@ -0,0 +1,61 @@ +package net.kdt.pojavlaunch.prefs; + +import static net.kdt.pojavlaunch.Tools.dialog; + +import android.content.Context; +import android.text.InputType; +import android.util.AttributeSet; +import android.widget.EditText; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AlertDialog; +import androidx.preference.SwitchPreferenceCompat; + +import net.kdt.pojavlaunch.R; + +import java.util.Random; + +public class MathQuestionPreference extends SwitchPreferenceCompat { + public MathQuestionPreference(@NonNull Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + } + + @Override + protected void onClick() { + if (isChecked()) { // Don't ask for braincells if turning off + super.onClick(); + return; + } + Random random = new Random(); + int a = random.nextInt(10) + 1; + int b = random.nextInt(10) + 1; + int c = random.nextInt(10) + 1; + int d = random.nextInt(10) + 1; + int f = random.nextInt(10) + 1; + final int answer = (a * b) + c - d; + + final EditText input = new EditText(getContext()); + input.setInputType(InputType.TYPE_CLASS_NUMBER); + + new AlertDialog.Builder(getContext()) + .setTitle(R.string.sodium_math_warning_title) + .setMessage(this.getContext().getString(R.string.sodium_math_warning_message, a, b, c, d)) + .setView(input) + .setPositiveButton("OK", (dialog, which) -> { + try { + int userAnswer = Integer.parseInt(input.getText().toString()); + if (userAnswer == answer) { + super.onClick(); + } else { + dialog(getContext(), "Wrong!", "You failed the math test!"); + } + } catch (NumberFormatException e) { + Toast.makeText(getContext(), "Please enter a number.", Toast.LENGTH_SHORT).show(); + } + }) + .setNegativeButton("Cancel", null) + .show(); + } +} diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/JREUtils.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/JREUtils.java index 4c0f4f4c5..d95268b33 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/JREUtils.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/JREUtils.java @@ -214,7 +214,7 @@ public class JREUtils { } if(LOCAL_RENDERER != null) { - envMap.put("POJAV_RENDERER", LOCAL_RENDERER); + envMap.put("AMETHYST_RENDERER", LOCAL_RENDERER); if(LOCAL_RENDERER.equals("opengles3_ltw")) { envMap.put("LIBGL_ES", "3"); envMap.put("POJAVEXEC_EGL","libltw.so"); // Use ANGLE EGL diff --git a/app_pojavlauncher/src/main/jni/ctxbridges/gl_bridge.c b/app_pojavlauncher/src/main/jni/ctxbridges/gl_bridge.c index 0b9ad99a4..4fb9503c3 100644 --- a/app_pojavlauncher/src/main/jni/ctxbridges/gl_bridge.c +++ b/app_pojavlauncher/src/main/jni/ctxbridges/gl_bridge.c @@ -77,7 +77,7 @@ gl_render_window_t* gl_init_context(gl_render_window_t *share) { { EGLBoolean bindResult; - if (strncmp(getenv("POJAV_RENDERER"), "opengles3_desktopgl", 19) == 0) { + if (strncmp(getenv("AMETHYST_RENDERER"), "opengles3_desktopgl", 19) == 0) { printf("EGLBridge: Binding to desktop OpenGL\n"); bindResult = eglBindAPI_p(EGL_OPENGL_API); } else { diff --git a/app_pojavlauncher/src/main/jni/egl_bridge.c b/app_pojavlauncher/src/main/jni/egl_bridge.c index f4e5760ae..563436276 100644 --- a/app_pojavlauncher/src/main/jni/egl_bridge.c +++ b/app_pojavlauncher/src/main/jni/egl_bridge.c @@ -162,7 +162,7 @@ int pojavInitOpenGL() { pojav_environ->force_vsync = true; // NOTE: Override for now. - const char *renderer = getenv("POJAV_RENDERER"); + const char *renderer = getenv("AMETHYST_RENDERER"); if (strncmp("opengles", renderer, 8) == 0) { pojav_environ->config_renderer = RENDERER_GL4ES; if (!strcmp(renderer, "opengles3_desktopgl_zink_kopper")) { diff --git a/app_pojavlauncher/src/main/res/values/strings.xml b/app_pojavlauncher/src/main/res/values/strings.xml index 4c9afe5e8..b118c6a18 100644 --- a/app_pojavlauncher/src/main/res/values/strings.xml +++ b/app_pojavlauncher/src/main/res/values/strings.xml @@ -487,4 +487,17 @@ AMD FSR 1 Upscaling Auto-renderer select failed, defaulting to HolyGL4ES Kopper Zink (Vulkan) - (all versions, mid) + Sodium detected! + It appears you are using sodium, this is unsupported and may lead to graphical issues or crashes. Please remove it and all dependent mods. + Delete Sodium and Launch + Run sodium forcefully + Using sodium may cause visual bugs and crashes. You have been warned. + Sodium is not supported. No help will be given if you encounter any issues. + + Solve the math question to enable + + Sodium is unsupported, you are on your own. You have been warned.\n + Now what\'s %1$d multiplied by %2$d plus %3$d minus %4$d? + + diff --git a/app_pojavlauncher/src/main/res/xml/pref_experimental.xml b/app_pojavlauncher/src/main/res/xml/pref_experimental.xml index 4697c4b78..c3536d559 100644 --- a/app_pojavlauncher/src/main/res/xml/pref_experimental.xml +++ b/app_pojavlauncher/src/main/res/xml/pref_experimental.xml @@ -14,6 +14,12 @@ android:key="bigCoreAffinity" android:title="@string/preference_force_big_core_title" android:summary="@string/preference_force_big_core_desc" /> + \ No newline at end of file diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFW.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFW.java index 4abc22a6f..47dde7468 100644 --- a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFW.java +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFW.java @@ -1005,20 +1005,20 @@ public class GLFW boolean turnipLoad = System.getenv("POJAV_LOAD_TURNIP") != null && System.getenv("POJAV_LOAD_TURNIP").equals("1"); // These values can be found at headings_array.xml - if (turnipLoad && System.getenv("POJAV_RENDERER").equals("vulkan_zink")) { + if (turnipLoad && System.getenv("AMETHYST_RENDERER").equals("vulkan_zink")) { System.out.println("GLFW: Turnip+Zink detected, setting GL context to 4.6"); glMajor = 4; glMinor = 6; - } else if (System.getenv("POJAV_RENDERER").equals("opengles3_virgl")) { + } else if (System.getenv("AMETHYST_RENDERER").equals("opengles3_virgl")) { System.out.println("GLFW: virglrenderer detected, setting GL context to 4.3"); glMajor = 4; glMinor = 3; - } else if (System.getenv("POJAV_RENDERER").equals("opengles_mobileglues")) { + } else if (System.getenv("AMETHYST_RENDERER").equals("opengles_mobileglues")) { System.out.println("GLFW: MobileGlues detected, setting GL context to 4.0"); glMajor = 4; glMinor = 0; } else { - System.out.println("GLFW: " + System.getenv("POJAV_RENDERER") + " detected, defaulting GL context to 3.3"); + System.out.println("GLFW: " + System.getenv("AMETHYST_RENDERER") + " detected, defaulting GL context to 3.3"); } win.windowAttribs.put(GLFW_CONTEXT_VERSION_MAJOR, glMajor); win.windowAttribs.put(GLFW_CONTEXT_VERSION_MINOR, glMinor);