Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,10 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {

private void runCraft(String versionId, JMinecraftVersionList.Version version) throws Throwable {
if(Tools.LOCAL_RENDERER == null) {
Tools.LOCAL_RENDERER = LauncherPreferences.PREF_RENDERER;
Integer iSelectedMcVer = Tools.mcVersiontoInt(Tools.getSelectedVanillaMcVer());
if (iSelectedMcVer >= 1021005) {
Tools.LOCAL_RENDERER = "opengles_mobileglues";
} else Tools.LOCAL_RENDERER = "opengles2";
}
if(!Tools.checkRendererCompatible(this, Tools.LOCAL_RENDERER)) {
Tools.RenderersList renderersList = Tools.getCompatibleRenderers(this);
Expand Down
47 changes: 46 additions & 1 deletion app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Tools.java
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,9 @@ public static void showErrorRemote(String rolledMessage, Throwable e) {
public static void dialogOnUiThread(final Activity activity, final CharSequence title, final CharSequence message) {
activity.runOnUiThread(()->dialog(activity, title, message));
}
public static void dialogOnUiThread(final Activity activity, final int title, final int message) {
dialogOnUiThread(activity, activity.getString(title), activity.getString(message));
}

public static void dialog(final Context context, final CharSequence title, final CharSequence message) {
new AlertDialog.Builder(context)
Expand Down Expand Up @@ -1506,5 +1509,47 @@ public static void hasNoOnlineProfileDialog(Activity activity, String customTitl
hasNoOnlineProfileDialog(activity, null, customTitle, customMessage);
}


public static String getSelectedVanillaMcVer(){
String selectedProfile = LauncherPreferences.DEFAULT_PREF.getString(LauncherPreferences.PREF_KEY_CURRENT_PROFILE, "");
MinecraftProfile selected = LauncherProfiles.mainProfileJson.profiles.get(selectedProfile);
if (selected == null) { // This should NEVER happen.
throw new RuntimeException("No profile selected, how did you reach this? Go ask in the discord or github");
}
String currentMCVersion = selected.lastVersionId;
String vanillaVersion = currentMCVersion;
File providedJsonFile = new File(Tools.DIR_HOME_VERSION + "/" + currentMCVersion + "/" + currentMCVersion + ".json");
JMinecraftVersionList.Version providedJsonVersion = null;
try {
providedJsonVersion = Tools.GLOBAL_GSON.fromJson(Tools.read(providedJsonFile.getAbsolutePath()), JMinecraftVersionList.Version.class);
} catch (IOException e) {
throw new RuntimeException(e);
}
try {
vanillaVersion = providedJsonVersion.inheritsFrom != null ? providedJsonVersion.inheritsFrom : vanillaVersion;
} catch (NullPointerException e) {
throw new RuntimeException(e);
}
return vanillaVersion;
}

public static Integer mcVersiontoInt(String mcVersion){
String[] sVersionArray = mcVersion.split("\\.");
String[] iVersionArray = new String[3];
// Make sure this is actually a version string
for (int i = 0; i < iVersionArray.length; i++) {
// Ensure there's padding
sVersionArray[i] = String.format("%3s", sVersionArray[i]).replace(' ', '0');
System.out.println(sVersionArray[i]);
// Grab only the last 3, MCJE 999.999.999 isnt coming soon anyway
sVersionArray[i] = sVersionArray[i].substring(sVersionArray[i].length() - 3);
try {
// Verify its a real deal, legit number
Integer.parseInt(sVersionArray[i]);
iVersionArray[i] = sVersionArray[i];
} catch (NumberFormatException e) {
throw new RuntimeException("Tools(mcVersiontoInt): Invalid version string");
}
}
return Integer.parseInt(iVersionArray[0] + iVersionArray[1] + iVersionArray[2]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public class LauncherPreferences {
public static final String PREF_KEY_SKIP_NOTIFICATION_CHECK = "skipNotificationPermissionCheck";

public static SharedPreferences DEFAULT_PREF;
public static String PREF_RENDERER = "opengles2";

public static boolean PREF_IGNORE_NOTCH = false;
public static int PREF_NOTCH_SIZE = 0;
Expand Down Expand Up @@ -79,7 +78,6 @@ public static void loadPreferences(Context ctx) {
Tools.initStorageConstants(ctx);
boolean isDevicePowerful = isDevicePowerful(ctx);

PREF_RENDERER = DEFAULT_PREF.getString("renderer", "opengles2");
PREF_BUTTONSIZE = DEFAULT_PREF.getInt("buttonscale", 100);
PREF_MOUSESCALE = DEFAULT_PREF.getInt("mousescale", 100)/100f;
PREF_MOUSESPEED = ((float)DEFAULT_PREF.getInt("mousespeed",100))/100f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ public void onCreatePreferences(Bundle b, String str) {
requirePreference("alternate_surface", SwitchPreferenceCompat.class).setChecked(LauncherPreferences.PREF_USE_ALTERNATE_SURFACE);
requirePreference("force_vsync", SwitchPreferenceCompat.class).setChecked(LauncherPreferences.PREF_FORCE_VSYNC);

ListPreference rendererListPreference = requirePreference("renderer",
ListPreference.class);
Tools.RenderersList renderersList = Tools.getCompatibleRenderers(getContext());
rendererListPreference.setEntries(renderersList.rendererDisplayNames);
rendererListPreference.setEntryValues(renderersList.rendererIds.toArray(new String[0]));

computeVisibility();
}

Expand Down
2 changes: 1 addition & 1 deletion app_pojavlauncher/src/main/res/values-en-rGB/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<string name="mcl_setting_title_javaargs">JVM Launch arguments</string>
<string name="mcl_setting_subtitle_javaargs">Be careful, this may make game crash if modified without knowledge.</string>
<string name="mcl_setting_category_renderer">Renderer</string>
<string name="mcl_setting_renderer_gles2_4">Holy GL4ES - (all versions, fast)</string>
<string name="mcl_setting_renderer_gles2_4">Holy GL4ES - (1.21.4&lt; only, fast)</string>
<string name="mcl_setting_renderer_vulkan_zink">Zink (Vulkan) - (all versions, mid)</string>
<string name="mcl_setting_veroption_release">Release</string>
<string name="mcl_setting_veroption_snapshot">Snapshot</string>
Expand Down
2 changes: 1 addition & 1 deletion app_pojavlauncher/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<string name="mcl_setting_title_renderer_settings">Extra Renderer Settings</string>
<string name="mcl_setting_title_renderer_subtitle">Renderer specific settings</string>
<string name="mcl_setting_category_renderer">Renderer</string>
<string name="mcl_setting_renderer_gles2_4">Holy GL4ES - (all versions, fast)</string>
<string name="mcl_setting_renderer_gles2_4">Holy GL4ES - (1.21.4&lt; only, fast)</string>
<string name="mcl_setting_renderer_vulkan_zink">Zink (Vulkan) - (all versions, mid)</string>
<string name="mcl_setting_renderer_mobileglues">MobileGlues (OpenGL ES) - (1.17+ only, fast)</string>
<string name="mcl_setting_renderer_ltw">LTW (OpenGL ES 3) - 1.17+ only</string>
Expand Down
8 changes: 1 addition & 7 deletions app_pojavlauncher/src/main/res/xml/pref_video.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,10 @@
<net.kdt.pojavlaunch.prefs.BackButtonPreference/>

<PreferenceCategory android:title="@string/preference_category_video" >
<androidx.preference.ListPreference
android:title="@string/mcl_setting_category_renderer"
android:key="renderer"
android:defaultValue="opengles2"
android:icon="@drawable/ic_setting_engine"
app2:useSimpleSummaryProvider="true"/>

<Preference
android:title="@string/mcl_setting_title_renderer_settings"
android:summary="@string/mcl_setting_title_renderer_subtitle"
android:icon="@drawable/ic_setting_engine"
android:fragment="net.kdt.pojavlaunch.prefs.screens.LauncherPreferenceRendererSettingsFragment"
/>

Expand Down
Loading