mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2026-04-19 00:56:57 -04:00
Merge pull request #148 from alexytomi/add/sodium-warning
add: Sodium warning
This commit is contained in:
Binary file not shown.
@@ -1 +1 @@
|
||||
b35956195a536dfa5895ca6d40d13c718de4d7fa
|
||||
276e966873587ef19ddad2f320052b8c10ff7a77
|
||||
@@ -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;
|
||||
|
||||
@@ -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()));
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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")) {
|
||||
|
||||
@@ -487,4 +487,17 @@
|
||||
<string name="mg_renderer_title_fsr">AMD FSR 1 Upscaling</string>
|
||||
<string name="autorendererselectfailed">Auto-renderer select failed, defaulting to HolyGL4ES</string>
|
||||
<string name="mcl_setting_renderer_vulkan_kopper_zink">Kopper Zink (Vulkan) - (all versions, mid)</string>
|
||||
<string name="sodium_warning_title">Sodium detected!</string>
|
||||
<string name="sodium_warning_message">It appears you are using sodium, this is unsupported and may lead to graphical issues or crashes. Please remove it and all dependent mods.</string>
|
||||
<string name="delete_sodium">Delete Sodium and Launch</string>
|
||||
<string name="sodium_override_title">Run sodium forcefully</string>
|
||||
<string name="sodium_override_summaryOff">Using sodium may cause visual bugs and crashes. You have been warned.</string>
|
||||
<string name="sodium_override_summaryOn">Sodium is not supported. No help will be given if you encounter any issues.</string>
|
||||
<!-- Make sure the people turning this on can read English. -->
|
||||
<string name="sodium_math_warning_title" translatable="false">Solve the math question to enable</string>
|
||||
<string name="sodium_math_warning_message" translatable="false">
|
||||
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?
|
||||
</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -14,6 +14,12 @@
|
||||
android:key="bigCoreAffinity"
|
||||
android:title="@string/preference_force_big_core_title"
|
||||
android:summary="@string/preference_force_big_core_desc" />
|
||||
<net.kdt.pojavlaunch.prefs.MathQuestionPreference
|
||||
android:title="@string/sodium_override_title"
|
||||
android:summaryOff="@string/sodium_override_summaryOff"
|
||||
android:summaryOn="@string/sodium_override_summaryOn"
|
||||
android:key="sodium_override"
|
||||
/>
|
||||
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user