Merge pull request #4 from khanhduytran0/regal

Regal
This commit is contained in:
khanhduytran0 2020-04-15 14:19:39 +07:00 committed by GitHub
commit 322dd12700
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 332 additions and 5 deletions

Binary file not shown.

View File

@ -926,7 +926,7 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
String[] optifineInfo = mVersionInfo.optifineLib.name.split(":"); String[] optifineInfo = mVersionInfo.optifineLib.name.split(":");
String optifineJar = Tools.libraries + "/" + Tools.artifactToPath(optifineInfo[0], optifineInfo[1], optifineInfo[2]); String optifineJar = Tools.libraries + "/" + Tools.artifactToPath(optifineInfo[0], optifineInfo[1], optifineInfo[2]);
AndroidOptiFineUtilities.originalOptifineJar = optifineJar; AndroidOptiFineUtilities.originalOptifineJar = PojavPreferenceActivity.PREF_FORGETOF ? "/null/file.jar" : optifineJar;
} }
File optDir = getDir("dalvik-cache", 0); File optDir = getDir("dalvik-cache", 0);

View File

@ -11,11 +11,12 @@ import com.kdt.mcgui.app.*;
public class PojavPreferenceActivity extends MineActivity public class PojavPreferenceActivity extends MineActivity
{ {
public static boolean PREF_FREEFORM = false; public static boolean PREF_FREEFORM = false;
public static boolean PREF_FORGETOF = false;
public static float PREF_BUTTONSIZE = 1.0f; public static float PREF_BUTTONSIZE = 1.0f;
private SeekBar viewSeekDxRef, viewSeekControlSize; private SeekBar viewSeekDxRef, viewSeekControlSize;
private TextView viewSeekProgressDxRef, viewSeekProgressControl; private TextView viewSeekProgressDxRef, viewSeekProgressControl;
private Switch viewSwitchFreeform; private Switch viewSwitchFreeform, viewSwitchForgetOF;
private SharedPreferences mainPreference; private SharedPreferences mainPreference;
@Override @Override
@ -101,6 +102,19 @@ public class PojavPreferenceActivity extends MineActivity
}); });
viewSwitchFreeform.setChecked(PREF_FREEFORM); viewSwitchFreeform.setChecked(PREF_FREEFORM);
viewSwitchFreeform.setEnabled(Build.VERSION.SDK_INT >= 24); viewSwitchFreeform.setEnabled(Build.VERSION.SDK_INT >= 24);
// Forget OptiFine path
viewSwitchForgetOF = (Switch) findViewById(R.id.settings_switch_forgetoptifpath);
viewSwitchForgetOF.setOnCheckedChangeListener(new Switch.OnCheckedChangeListener(){
@Override
public void onCheckedChanged(CompoundButton b, boolean z)
{
mainPrefEdit.putBoolean("forgetOptifinePath", z);
mainPrefEdit.commit();
}
});
viewSwitchForgetOF.setChecked(PREF_FORGETOF);
} }
@Override @Override
@ -118,5 +132,6 @@ public class PojavPreferenceActivity extends MineActivity
PREF_BUTTONSIZE = mainPreference.getFloat("controlSize", 1f); PREF_BUTTONSIZE = mainPreference.getFloat("controlSize", 1f);
PREF_FREEFORM = mainPreference.getBoolean("freeform", false); PREF_FREEFORM = mainPreference.getBoolean("freeform", false);
PREF_FORGETOF = mainPreference.getBoolean("forgetOptifinePath", false);
} }
} }

View File

@ -4,6 +4,4 @@ public class AndroidOptiFineUtilities
{ {
public static volatile String originalOptifineJar; public static volatile String originalOptifineJar;
public static volatile String optifineOutputJar; public static volatile String optifineOutputJar;
// public sta
} }

View File

@ -0,0 +1,286 @@
/*
* Copyright (c) 2002-2008 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl;
import java.nio.*;
/**
* <p>A class to check buffer boundaries in general. If there is unsufficient space
* in the buffer when the call is made then a buffer overflow would otherwise
* occur and cause unexpected behaviour, a crash, or worse, a security risk.
*
* Internal class, don't use.
* </p>
* @author cix_foo <cix_foo@users.sourceforge.net>
* @author elias_naur <elias_naur@users.sourceforge.net>
* @version $Revision$
* $Id$
*/
public class BufferChecks {
/** Static methods only! */
private BufferChecks() {
}
/**
* Helper methods to ensure a function pointer is not-null (0)
*/
public static void checkFunctionAddress(long pointer) {
if (LWJGLUtil.CHECKS && pointer == 0) {
// throw new IllegalStateException("Function is not supported");
}
}
/**
* Helper methods to ensure a ByteBuffer is null-terminated
*/
public static void checkNullTerminated(ByteBuffer buf) {
if ( LWJGLUtil.CHECKS && buf.get(buf.limit() - 1) != 0) {
throw new IllegalArgumentException("Missing null termination");
}
}
public static void checkNullTerminated(ByteBuffer buf, int count) {
if ( LWJGLUtil.CHECKS ) {
int nullFound = 0;
for ( int i = buf.position(); i < buf.limit(); i++ ) {
if ( buf.get(i) == 0 )
nullFound++;
}
if ( nullFound < count )
throw new IllegalArgumentException("Missing null termination");
}
}
/** Helper method to ensure an IntBuffer is null-terminated */
public static void checkNullTerminated(IntBuffer buf) {
if ( LWJGLUtil.CHECKS && buf.get(buf.limit() - 1) != 0 ) {
throw new IllegalArgumentException("Missing null termination");
}
}
/** Helper method to ensure a LongBuffer is null-terminated */
public static void checkNullTerminated(LongBuffer buf) {
if ( LWJGLUtil.CHECKS && buf.get(buf.limit() - 1) != 0 ) {
throw new IllegalArgumentException("Missing null termination");
}
}
/** Helper method to ensure a PointerBuffer is null-terminated */
public static void checkNullTerminated(PointerBuffer buf) {
if ( LWJGLUtil.CHECKS && buf.get(buf.limit() - 1) != 0 ) {
throw new IllegalArgumentException("Missing null termination");
}
}
public static void checkNotNull(Object o) {
if ( LWJGLUtil.CHECKS && o == null)
throw new IllegalArgumentException("Null argument");
}
/**
* Helper methods to ensure a buffer is direct (and, implicitly, non-null).
*/
public static void checkDirect(ByteBuffer buf) {
if ( LWJGLUtil.CHECKS && !buf.isDirect()) {
throw new IllegalArgumentException("ByteBuffer is not direct");
}
}
public static void checkDirect(ShortBuffer buf) {
if ( LWJGLUtil.CHECKS && !buf.isDirect()) {
throw new IllegalArgumentException("ShortBuffer is not direct");
}
}
public static void checkDirect(IntBuffer buf) {
if ( LWJGLUtil.CHECKS && !buf.isDirect()) {
throw new IllegalArgumentException("IntBuffer is not direct");
}
}
public static void checkDirect(LongBuffer buf) {
if ( LWJGLUtil.CHECKS && !buf.isDirect()) {
throw new IllegalArgumentException("LongBuffer is not direct");
}
}
public static void checkDirect(FloatBuffer buf) {
if ( LWJGLUtil.CHECKS && !buf.isDirect()) {
throw new IllegalArgumentException("FloatBuffer is not direct");
}
}
public static void checkDirect(DoubleBuffer buf) {
if ( LWJGLUtil.CHECKS && !buf.isDirect()) {
throw new IllegalArgumentException("DoubleBuffer is not direct");
}
}
public static void checkDirect(PointerBuffer buf) {
// NO-OP, PointerBuffer is always direct.
}
public static void checkArray(Object[] array) {
if ( LWJGLUtil.CHECKS && (array == null || array.length == 0) )
throw new IllegalArgumentException("Invalid array");
}
/**
* This is a separate call to help inline checkBufferSize.
*/
private static void throwBufferSizeException(Buffer buf, int size) {
throw new IllegalArgumentException("Number of remaining buffer elements is " + buf.remaining() + ", must be at least " + size + ". Because at most " + size + " elements can be returned, a buffer with at least " + size + " elements is required, regardless of actual returned element count");
}
private static void throwBufferSizeException(PointerBuffer buf, int size) {
throw new IllegalArgumentException("Number of remaining pointer buffer elements is " + buf.remaining() + ", must be at least " + size);
}
private static void throwArraySizeException(Object[] array, int size) {
throw new IllegalArgumentException("Number of array elements is " + array.length + ", must be at least " + size);
}
private static void throwArraySizeException(long[] array, int size) {
throw new IllegalArgumentException("Number of array elements is " + array.length + ", must be at least " + size);
}
/**
* Helper method to ensure a buffer is big enough to receive data from a
* glGet* operation.
*
* @param buf
* The buffer to check
* @param size
* The minimum buffer size
* @throws IllegalArgumentException
*/
public static void checkBufferSize(Buffer buf, int size) {
if ( LWJGLUtil.CHECKS && buf.remaining() < size) {
throwBufferSizeException(buf, size);
}
}
/**
* Detects the buffer type and performs the corresponding check
* and also returns the buffer position in bytes.
*
* @param buffer the buffer to check
* @param size the size to check
*
* @return the buffer position in bytes
*/
public static int checkBuffer(final Buffer buffer, final int size) {
final int posShift;
if ( buffer instanceof ByteBuffer ) {
BufferChecks.checkBuffer((ByteBuffer)buffer, size);
posShift = 0;
} else if ( buffer instanceof ShortBuffer ) {
BufferChecks.checkBuffer((ShortBuffer)buffer, size);
posShift = 1;
} else if ( buffer instanceof IntBuffer ) {
BufferChecks.checkBuffer((IntBuffer)buffer, size);
posShift = 2;
} else if ( buffer instanceof LongBuffer ) {
BufferChecks.checkBuffer((LongBuffer)buffer, size);
posShift = 4;
} else if ( buffer instanceof FloatBuffer ) {
BufferChecks.checkBuffer((FloatBuffer)buffer, size);
posShift = 2;
} else if ( buffer instanceof DoubleBuffer ) {
BufferChecks.checkBuffer((DoubleBuffer)buffer, size);
posShift = 4;
} else
throw new IllegalArgumentException("Unsupported Buffer type specified: " + buffer.getClass());
return buffer.position() << posShift;
}
public static void checkBuffer(ByteBuffer buf, int size) {
if ( LWJGLUtil.CHECKS ) {
checkBufferSize(buf, size);
checkDirect(buf);
}
}
public static void checkBuffer(ShortBuffer buf, int size) {
if ( LWJGLUtil.CHECKS ) {
checkBufferSize(buf, size);
checkDirect(buf);
}
}
public static void checkBuffer(IntBuffer buf, int size) {
if ( LWJGLUtil.CHECKS ) {
checkBufferSize(buf, size);
checkDirect(buf);
}
}
public static void checkBuffer(LongBuffer buf, int size) {
if ( LWJGLUtil.CHECKS ) {
checkBufferSize(buf, size);
checkDirect(buf);
}
}
public static void checkBuffer(FloatBuffer buf, int size) {
if ( LWJGLUtil.CHECKS ) {
checkBufferSize(buf, size);
checkDirect(buf);
}
}
public static void checkBuffer(DoubleBuffer buf, int size) {
if ( LWJGLUtil.CHECKS ) {
checkBufferSize(buf, size);
checkDirect(buf);
}
}
public static void checkBuffer(PointerBuffer buf, int size) {
if ( LWJGLUtil.CHECKS && buf.remaining() < size ) {
throwBufferSizeException(buf, size);
}
}
public static void checkArray(Object[] array, int size) {
if ( LWJGLUtil.CHECKS && array.length < size )
throwArraySizeException(array, size);
}
public static void checkArray(long[] array, int size) {
if ( LWJGLUtil.CHECKS && array.length < size )
throwArraySizeException(array, size);
}
}

View File

@ -107,5 +107,31 @@
android:layout_height="2dp" android:layout_height="2dp"
android:layout_width="match_parent"/> android:layout_width="match_parent"/>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_margin="10dp">
<TextView
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:text="@string/mcl_setting_title_forgetoptifpath"
android:textStyle="bold"/>
<Switch
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="@+id/settings_switch_forgetoptifpath"
android:text="@string/mcl_setting_subtitle_forgetoptifpath"/>
</LinearLayout>
<View
android:background="?android:attr/dividerVertical"
android:layout_height="2dp"
android:layout_width="match_parent"/>
</LinearLayout> </LinearLayout>

View File

@ -95,7 +95,9 @@
<string name="mcl_setting_subtitle_setmaxdxref">Increase If an error happend while converting: Too many ... references. You may try multi-dex option.</string> <string name="mcl_setting_subtitle_setmaxdxref">Increase If an error happend while converting: Too many ... references. You may try multi-dex option.</string>
<string name="mcl_setting_enablefreeform">Enable Freeform mode for launch Minecraft (Android 7.0+)</string> <string name="mcl_setting_enablefreeform">Enable Freeform mode for launch Minecraft (Android 7.0+)</string>
<string name="mcl_setting_title_controlsize">Set control buttons size</string> <string name="mcl_setting_title_controlsize">Set control buttons size</string>
<string name="mcl_setting_title_forgetoptifpath">Make OptiFine unable to locate itself</string>
<string name="mcl_setting_subtitle_forgetoptifpath">Useful for making OptiFine launchable on some devices</string>
<string name="mcl_version_clone">Clone</string> <string name="mcl_version_clone">Clone</string>
<!-- Global strings --> <!-- Global strings -->