Compare commits
33
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ff539fb66 | ||
|
|
c5b79ab4ab | ||
|
|
21a6cb7074 | ||
|
|
8df8c90d34 | ||
|
|
0932fcad09 | ||
|
|
f02ae570c6 | ||
|
|
a5d020da94 | ||
|
|
3a450ae911 | ||
|
|
3bbec01507 | ||
|
|
7c68a3ac2a | ||
|
|
f8a73da290 | ||
|
|
8f7b17955a | ||
|
|
9a7981138f | ||
|
|
21c4b8d056 | ||
|
|
d5774ca006 | ||
|
|
0d2cd19b84 | ||
|
|
5b12c7bfb4 | ||
|
|
9d4b607003 | ||
|
|
234c1eaf9a | ||
|
|
457311354b | ||
|
|
a3a58aaa0a | ||
|
|
c0122c2a72 | ||
|
|
b82cb2fc45 | ||
|
|
827ab9f4dc | ||
|
|
45dc25e16c | ||
|
|
1aa5a9651b | ||
|
|
4d81e7e843 | ||
|
|
57fc260eac | ||
|
|
05aafcbd27 | ||
|
|
e5a04c7e78 | ||
|
|
cb143956e4 | ||
|
|
a916648e45 | ||
|
|
57249f2d0c |
No files matched your search
+1
-1
@@ -50,7 +50,7 @@ deploy:
|
||||
api-key: $GITHUB_API_KEY
|
||||
file: $TRAVIS_BUILD_DIR/app/build/outputs/apk/debug/app-debug.apk
|
||||
skip_cleanup: true
|
||||
name: autobuild-$TRAVIS_COMMIT
|
||||
name: PojavLauncher_DevBuild-$TRAVIS_COMMIT
|
||||
body: Automatic build of PojavLauncher from the latest source commit ($TRAVIS_COMMIT) built by Travis CI on $(date +'%F %T %Z').
|
||||
prerelease: true
|
||||
overwrite: true
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -15,6 +15,9 @@
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:roundIcon="@drawable/ic_launcher"
|
||||
android:resizeableActivity="true">
|
||||
<meta-data
|
||||
android:name="android.max_aspect"
|
||||
android:value="ratio_float"/>
|
||||
|
||||
<activity
|
||||
android:screenOrientation="sensorLandscape"
|
||||
@@ -29,6 +32,7 @@
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:theme="@style/MenuDialog"
|
||||
android:screenOrientation="sensorLandscape"
|
||||
android:name=".FatalErrorActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"/>
|
||||
@@ -47,7 +51,6 @@
|
||||
android:launchMode="standard"
|
||||
android:multiprocess="true"
|
||||
android:screenOrientation="sensorLandscape"
|
||||
android:theme="@style/RunTheme"
|
||||
android:name=".MainActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"/>
|
||||
|
||||
@@ -60,6 +63,7 @@
|
||||
android:screenOrientation="sensorLandscape"
|
||||
android:name=".prefs.PojavPreferenceActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"/>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
Binary file not shown.
@@ -0,0 +1,29 @@
|
||||
package com.android.internal.awt;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class AndroidGraphicsDevice extends GraphicsDevice
|
||||
{
|
||||
public GraphicsConfiguration[] mConfigurations = new GraphicsConfiguration[]{new AndroidGraphicsConfiguration()};
|
||||
|
||||
@Override
|
||||
public GraphicsConfiguration[] getConfigurations() {
|
||||
return mConfigurations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphicsConfiguration getDefaultConfiguration() {
|
||||
return mConfigurations[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIDstring() {
|
||||
return "Android";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return TYPE_IMAGE_BUFFER;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* @author Alexey A. Petrenko, Oleg V. Khaschansky
|
||||
* @version $Revision$
|
||||
*/
|
||||
|
||||
package com.android.internal.awt;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.apache.harmony.awt.gl.CommonGraphicsEnvironment;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* AndroidGraphicsEnvironment implementation
|
||||
*
|
||||
*/
|
||||
public class AndroidGraphicsEnvironment extends CommonGraphicsEnvironment
|
||||
{
|
||||
public GraphicsDevice[] mGraphicsDevices = new GraphicsDevice[]{new AndroidGraphicsDevice()};
|
||||
|
||||
@Override
|
||||
public GraphicsDevice getDefaultScreenDevice() throws HeadlessException {
|
||||
return mGraphicsDevices[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphicsDevice[] getScreenDevices() throws HeadlessException {
|
||||
return mGraphicsDevices;
|
||||
}
|
||||
}
|
||||
@@ -34,12 +34,12 @@ import org.apache.harmony.awt.gl.CommonGraphics2DFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.content.Context;
|
||||
import org.apache.harmony.awt.gl.*;
|
||||
|
||||
public class AndroidGraphicsFactory extends CommonGraphics2DFactory {
|
||||
|
||||
public GraphicsEnvironment createGraphicsEnvironment(WindowFactory wf) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return new AndroidGraphicsEnvironment();
|
||||
}
|
||||
|
||||
public Font embedFont(String fontFilePath) {
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
|
||||
package java.awt;
|
||||
|
||||
import org.apache.harmony.awt.internal.nls.Messages;
|
||||
import org.apache.harmony.awt.internal.nls.*;
|
||||
import org.lwjgl.opengl.*;
|
||||
|
||||
/**
|
||||
* The GraphicsDevice class describes the graphics devices (such as screens or
|
||||
@@ -62,7 +63,7 @@ public abstract class GraphicsDevice {
|
||||
* Constructor is not to be used directly as this class is abstract.
|
||||
*/
|
||||
protected GraphicsDevice() {
|
||||
displayMode = new DisplayMode(0, 0, DisplayMode.BIT_DEPTH_MULTI,
|
||||
displayMode = new DisplayMode(AndroidDisplay.windowWidth, AndroidDisplay.windowHeight, DisplayMode.BIT_DEPTH_MULTI,
|
||||
DisplayMode.REFRESH_RATE_UNKNOWN);
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,10 @@ public abstract class GraphicsEnvironment {
|
||||
* keyboard, or mouse, false otherwise.
|
||||
*/
|
||||
public static boolean isHeadless() {
|
||||
return "true".equals(System.getProperty("java.awt.headless"));
|
||||
return false;
|
||||
|
||||
// Disable headless...
|
||||
// "true".equals(System.getProperty("java.awt.headless"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -169,14 +169,17 @@ public final class HeadlessToolkit extends ToolkitImpl {
|
||||
try {
|
||||
ComponentInternals.setComponentInternals(new ComponentInternalsImpl());
|
||||
// ???AWT: new EventQueue(this); // create the system EventQueue
|
||||
// ???AWT: dispatcher = new Dispatcher(this);
|
||||
// ???AWT:
|
||||
dispatcher = new Dispatcher(this);
|
||||
desktopProperties = new HashMap<String, Object>();
|
||||
// ???AWT: desktopPropsSupport = new PropertyChangeSupport(this);
|
||||
// ???AWT: awtEventsManager = new AWTEventsManager();
|
||||
// ???AWT:
|
||||
awtEventsManager = new AWTEventsManager();
|
||||
// ???AWT: dispatchThread = new HeadlessEventDispatchThread(this,
|
||||
// dispatcher);
|
||||
// ???AWT: dtk = DTK.getDTK();
|
||||
dispatchThread.start();
|
||||
|
||||
// dispatchThread.start();
|
||||
} finally {
|
||||
unlockAWT();
|
||||
}
|
||||
|
||||
@@ -1,18 +1,73 @@
|
||||
package net.kdt.pojavlaunch;
|
||||
|
||||
import android.support.v7.app.*;
|
||||
import android.app.*;
|
||||
import android.content.*;
|
||||
import android.os.*;
|
||||
import android.support.v7.app.*;
|
||||
import android.util.*;
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.*;
|
||||
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
||||
public class FatalErrorActivity extends AppCompatActivity
|
||||
{
|
||||
public static void showError(Context ctx, String savePath, boolean storageAllow, /* boolean isFatalErr, */ Throwable th) {
|
||||
Intent ferrorIntent = new Intent(ctx, FatalErrorActivity.class);
|
||||
ferrorIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
ferrorIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
ferrorIntent.putExtra("throwable", th);
|
||||
ferrorIntent.putExtra("savePath", savePath);
|
||||
ferrorIntent.putExtra("storageAllow", storageAllow);
|
||||
// ferrorIntent.putExtra("isFatal", isFatalErr);
|
||||
ctx.startActivity(ferrorIntent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Bundle extras = getIntent().getExtras();
|
||||
Throwable th = (Throwable) extras.getSerializable("throwable");
|
||||
boolean isFatalError = extras.getBoolean("isFatal", false);
|
||||
boolean storageAllow = extras.getBoolean("storageAllow");
|
||||
final String strStackTrace = Log.getStackTraceString((Throwable) extras.getSerializable("throwable"));
|
||||
String strSavePath = extras.getString("savePath");
|
||||
String errHeader = storageAllow ?
|
||||
"Crash stack trace saved to " + strSavePath + "." :
|
||||
"Storage permission is required to save crash stack trace!";
|
||||
|
||||
Tools.showError(this, isFatalError ? R.string.error_fatal : R.string.global_error, th, true);
|
||||
// boolean isFatalError = extras.getBoolean("isFatal", false);
|
||||
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.error_fatal)
|
||||
.setMessage(errHeader + "\n\n" + strStackTrace)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface p1, int p2) {
|
||||
finish();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.global_restart, new DialogInterface.OnClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface p1, int p2) {
|
||||
startActivity(new Intent(FatalErrorActivity.this, PojavLoginActivity.class));
|
||||
}
|
||||
})
|
||||
.setNeutralButton(android.R.string.copy, new DialogInterface.OnClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface p1, int p2) {
|
||||
StringSelection errData = new StringSelection(strStackTrace);
|
||||
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(errData, null);
|
||||
|
||||
finish();
|
||||
}
|
||||
})
|
||||
//.setNegativeButton("Report (not available)", null)
|
||||
.setCancelable(false)
|
||||
.show();
|
||||
|
||||
// Tools.showError(this, isFatalError ? R.string.error_fatal : R.string.global_error, th, true);
|
||||
}
|
||||
}
|
||||
@@ -67,13 +67,29 @@ public class MCLauncherActivity extends AppCompatActivity
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
gson = new Gson();
|
||||
|
||||
DisplayMetrics dm = Tools.getDisplayMetrics(this);
|
||||
AndroidDisplay.windowWidth = dm.widthPixels;
|
||||
AndroidDisplay.windowHeight = dm.heightPixels;
|
||||
viewInit();
|
||||
|
||||
final View decorView = 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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
// DEBUG
|
||||
//new android.support.design.widget.NavigationView(this);
|
||||
@@ -400,9 +416,11 @@ public class MCLauncherActivity extends AppCompatActivity
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume()
|
||||
{
|
||||
protected void onResume(){
|
||||
super.onResume();
|
||||
final int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
|
||||
final View decorView = getWindow().getDecorView();
|
||||
decorView.setSystemUiVisibility(uiOptions);
|
||||
}
|
||||
|
||||
private boolean canBack = false;
|
||||
|
||||
@@ -121,6 +121,7 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
private boolean lastGrab = false;
|
||||
private boolean isExited = false;
|
||||
private boolean isLogAllow = false;
|
||||
private int navBarHeight = 40;
|
||||
|
||||
// private static Collection<? extends Provider.Service> rsaPkcs1List;
|
||||
|
||||
@@ -133,22 +134,23 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.main);
|
||||
|
||||
final View decorView = 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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
final View decorView = 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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ExitManager.setExitTrappedListener(new ExitManager.ExitTrappedListener(){
|
||||
@Override
|
||||
public void onExitTrapped()
|
||||
@@ -156,9 +158,14 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
runOnUiThread(new Runnable(){
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
public void run() {
|
||||
isExited = true;
|
||||
|
||||
try {
|
||||
SecondaryDexLoader.resetFieldArray(getClassLoader());
|
||||
} catch (Throwable th) {
|
||||
th.printStackTrace();
|
||||
}
|
||||
|
||||
AlertDialog.Builder d = new AlertDialog.Builder(MainActivity.this);
|
||||
d.setTitle(R.string.mcn_exit_title);
|
||||
@@ -194,6 +201,10 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
} catch (Throwable th) {
|
||||
Log.w(Tools.APP_NAME, "Could not disable System.exit() method!", th);
|
||||
}
|
||||
|
||||
File optDir = getDir("dalvik-cache", 0);
|
||||
optDir.mkdirs();
|
||||
launchOptimizedDirectory = optDir.getAbsolutePath();
|
||||
|
||||
mProfile = PojavProfile.getCurrentProfileContent(this);
|
||||
mVersionInfo = Tools.getVersionInfo(mProfile.getVersion());
|
||||
@@ -209,6 +220,14 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
System.loadLibrary("lwjgl_stb32");
|
||||
}
|
||||
*/
|
||||
|
||||
if (mVersionInfo.arguments == null) {
|
||||
// Minecraft 1.12 and below
|
||||
|
||||
// TODO uncomment after fix
|
||||
// SecondaryDexLoader.install(getClassLoader(), Arrays.asList(new File[]{new File(Tools.libraries + "/" + Tools.artifactToPath("org.lwjgl", "lwjglboardwalk", "2.9.1"))}), optDir);
|
||||
}
|
||||
|
||||
this.displayMetrics = Tools.getDisplayMetrics(this);
|
||||
|
||||
AndroidDisplay.windowWidth = displayMetrics.widthPixels / scaleFactor;
|
||||
@@ -659,6 +678,8 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
egl10.eglMakeCurrent(AndroidContextImplementation.display, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
|
||||
System.out.println(new StringBuffer().append("Gave up context: ").append(AndroidContextImplementation.context).toString());
|
||||
|
||||
AndroidDisplay.windowWidth += navBarHeight;
|
||||
|
||||
new Thread(new Runnable(){
|
||||
|
||||
@Override
|
||||
@@ -686,7 +707,7 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
});
|
||||
glSurfaceView.setPreserveEGLContextOnPause(true);
|
||||
glSurfaceView.setRenderMode(MinecraftGLView.RENDERMODE_CONTINUOUSLY);
|
||||
glSurfaceView.requestRender();
|
||||
// glSurfaceView.requestRender();
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
Tools.showError(this, e, true);
|
||||
@@ -743,7 +764,7 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mIsResuming = true;
|
||||
glSurfaceView.requestRender();
|
||||
if (glSurfaceView != null) glSurfaceView.requestRender();
|
||||
final int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
|
||||
final View decorView = getWindow().getDecorView();
|
||||
decorView.setSystemUiVisibility(uiOptions);
|
||||
@@ -982,6 +1003,18 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
public static String launchLibrarySearchPath;
|
||||
private void runCraft() throws Throwable //oncreate
|
||||
{
|
||||
LoggerJava.OnStringPrintListener printLog = new LoggerJava.OnStringPrintListener(){
|
||||
@Override
|
||||
public void onCharPrint(char c) {
|
||||
appendToLog(Character.toString(c));
|
||||
}
|
||||
};
|
||||
|
||||
PrintStream theStreamErr = new PrintStream(new LoggerJava.LoggerOutputStream(System.err, printLog));
|
||||
PrintStream theStreamOut = new PrintStream(new LoggerJava.LoggerOutputStream(System.out, printLog));
|
||||
System.setErr(theStreamErr);
|
||||
System.setOut(theStreamOut);
|
||||
|
||||
String[] launchArgs = getMCArgs();
|
||||
|
||||
// Setup OptiFine
|
||||
@@ -992,28 +1025,12 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||
AndroidOptiFineUtilities.originalOptifineJar = PojavPreferenceActivity.PREF_FORGETOF ? "/null/file.jar" : optifineJar;
|
||||
}
|
||||
|
||||
File optDir = getDir("dalvik-cache", 0);
|
||||
optDir.mkdirs();
|
||||
|
||||
launchClassPath = Tools.generate(mProfile.getVersion());
|
||||
launchOptimizedDirectory = optDir.getAbsolutePath();
|
||||
launchClassPath = Tools.generateLaunchClassPath(mProfile.getVersion());
|
||||
launchLibrarySearchPath = getApplicationInfo().nativeLibraryDir;
|
||||
|
||||
if (mVersionInfo.mainClass.equals("net.minecraft.launchwrapper.Launch")) {
|
||||
net.minecraft.launchwrapper.Launch.main(launchArgs);
|
||||
} else {
|
||||
LoggerJava.OnStringPrintListener printLog = new LoggerJava.OnStringPrintListener(){
|
||||
@Override
|
||||
public void onCharPrint(char c) {
|
||||
appendToLog(Character.toString(c));
|
||||
}
|
||||
};
|
||||
|
||||
PrintStream theStreamOut = new PrintStream(new LoggerJava.LoggerOutputStream(System.out, printLog));
|
||||
System.setOut(theStreamOut);
|
||||
// Redirect error stream to output stream
|
||||
System.setErr(theStreamOut);
|
||||
|
||||
/*
|
||||
PrintStream theStreamErr = new PrintStream(new LoggerJava.LoggerOutputStream(System.err, printLog));
|
||||
System.setErr(theStreamErr);
|
||||
|
||||
@@ -9,11 +9,47 @@ import net.kdt.pojavlaunch.value.customcontrols.*;
|
||||
import android.support.v7.preference.*;
|
||||
import java.io.*;
|
||||
import android.content.*;
|
||||
import android.support.v4.app.*;
|
||||
import android.util.*;
|
||||
import net.kdt.pojavlaunch.exit.*;
|
||||
import java.time.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
public class PojavApplication extends Application
|
||||
{
|
||||
public static String CRASH_REPORT_TAG = "PojavCrashReport";
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler(){
|
||||
@Override
|
||||
public void uncaughtException(Thread thread, Throwable th) {
|
||||
boolean storagePermAllowed = Build.VERSION.SDK_INT < 23 || ActivityCompat.checkSelfPermission(PojavApplication.this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
|
||||
File crashFile = new File(storagePermAllowed ? Tools.MAIN_PATH : Tools.datapath, "latestcrash.txt");
|
||||
try {
|
||||
// Write to file, since some devices may not able to show error
|
||||
crashFile.createNewFile();
|
||||
PrintStream crashStream = new PrintStream(crashFile);
|
||||
crashStream.append("PojavLauncher crash report\n");
|
||||
crashStream.append(" - Time: " + DateFormat.getDateTimeInstance().format(new Date()));
|
||||
crashStream.append(" - Device: " + Build.PRODUCT + " " + Build.MODEL);
|
||||
crashStream.append(" - Android version: " + Build.VERSION.RELEASE);
|
||||
crashStream.append(" - Crash stack trace:");
|
||||
crashStream.append(Log.getStackTraceString(th));
|
||||
crashStream.close();
|
||||
} catch (Throwable th2) {
|
||||
Log.e(CRASH_REPORT_TAG, " - Exception attempt saving crash stack trace:", th2);
|
||||
Log.e(CRASH_REPORT_TAG, " - The crash stack trace was:", th);
|
||||
}
|
||||
|
||||
FatalErrorActivity.showError(PojavApplication.this, crashFile.getAbsolutePath(), storagePermAllowed, th);
|
||||
// android.os.Process.killProcess(android.os.Process.myPid());
|
||||
|
||||
MainActivity.fullyExit();
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
super.onCreate();
|
||||
Tools.APP_NAME = getResources().getString(R.string.app_short_name);
|
||||
|
||||
@@ -32,6 +32,8 @@ public class PojavLoginActivity extends AppCompatActivity
|
||||
private int REQUEST_STORAGE_REQUEST_CODE = 1;
|
||||
private ProgressBar prb;
|
||||
private CheckBox sRemember, sOffline;
|
||||
private LinearLayout loginLayout;
|
||||
private ImageView imageLogo;
|
||||
|
||||
private boolean isPromptingGrant = false;
|
||||
// private boolean isPermGranted = false;
|
||||
@@ -234,8 +236,8 @@ public class PojavLoginActivity extends AppCompatActivity
|
||||
private void uiInit() {
|
||||
setContentView(R.layout.launcher_login_v2);
|
||||
|
||||
final LinearLayout loginLayout = findViewById(R.id.login_layout_linear);
|
||||
final ImageView imageLogo = findViewById(R.id.login_image_logo);
|
||||
loginLayout = findViewById(R.id.login_layout_linear);
|
||||
imageLogo = findViewById(R.id.login_image_logo);
|
||||
loginLayout.postDelayed(new Runnable(){
|
||||
@Override
|
||||
public void run(){
|
||||
@@ -264,6 +266,10 @@ public class PojavLoginActivity extends AppCompatActivity
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
if (loginLayout != null && imageLogo != null) {
|
||||
imageLogo.setTranslationY(loginLayout.getY() - (imageLogo.getHeight() / 2f));
|
||||
}
|
||||
|
||||
// Clear current profile
|
||||
PojavProfile.setCurrentProfile(this, null);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
package net.kdt.pojavlaunch;
|
||||
|
||||
import android.util.*;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.*;
|
||||
|
||||
/*
|
||||
* All methods there are from
|
||||
* https://android.googlesource.com/platform/frameworks/multidex/+/refs/heads/master/library/src/androidx/multidex/MultiDex.java
|
||||
*/
|
||||
public class SecondaryDexLoader
|
||||
{
|
||||
public static String TAG = "SecondaryDexLoader";
|
||||
|
||||
private static int ADDITIONAL_CLASSES = 0;
|
||||
|
||||
public static void install(ClassLoader loader, List<File> additionalClassPathEntries, File optimizedDirectory) throws Throwable {
|
||||
ADDITIONAL_CLASSES = additionalClassPathEntries.size();
|
||||
|
||||
/* The patched class loader is expected to be a descendant of
|
||||
* dalvik.system.BaseDexClassLoader. We modify its
|
||||
* dalvik.system.DexPathList pathList field to append additional DEX
|
||||
* file entries.
|
||||
*/
|
||||
|
||||
Object dexPathList = getDexPathList(loader);
|
||||
ArrayList<IOException> suppressedExceptions = new ArrayList<IOException>();
|
||||
expandFieldArray(dexPathList, "dexElements", makeDexElements(dexPathList,
|
||||
new ArrayList<File>(additionalClassPathEntries), optimizedDirectory,
|
||||
suppressedExceptions));
|
||||
if (suppressedExceptions.size() > 0) {
|
||||
for (IOException e : suppressedExceptions) {
|
||||
Log.w(TAG, "Exception in makeDexElement", e);
|
||||
}
|
||||
Field suppressedExceptionsField =
|
||||
findField(loader, "dexElementsSuppressedExceptions");
|
||||
IOException[] dexElementsSuppressedExceptions =
|
||||
(IOException[]) suppressedExceptionsField.get(loader);
|
||||
if (dexElementsSuppressedExceptions == null) {
|
||||
dexElementsSuppressedExceptions =
|
||||
suppressedExceptions.toArray(
|
||||
new IOException[suppressedExceptions.size()]);
|
||||
} else {
|
||||
IOException[] combined =
|
||||
new IOException[suppressedExceptions.size() +
|
||||
dexElementsSuppressedExceptions.length];
|
||||
suppressedExceptions.toArray(combined);
|
||||
System.arraycopy(dexElementsSuppressedExceptions, 0, combined,
|
||||
suppressedExceptions.size(), dexElementsSuppressedExceptions.length);
|
||||
dexElementsSuppressedExceptions = combined;
|
||||
}
|
||||
suppressedExceptionsField.set(loader, dexElementsSuppressedExceptions);
|
||||
}
|
||||
}
|
||||
|
||||
private static /* DexPathList */ Object getDexPathList(ClassLoader loader) throws Throwable {
|
||||
Field pathListField = findField(loader, "pathList");
|
||||
return pathListField.get(loader);
|
||||
}
|
||||
|
||||
/**
|
||||
* A wrapper around
|
||||
* {@code private static final dalvik.system.DexPathList#makeDexElements}.
|
||||
*/
|
||||
private static Object[] makeDexElements(Object dexPathList, ArrayList<File> files, File optimizedDirectory, ArrayList<IOException> suppressedExceptions) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
|
||||
Method makeDexElements = findMethod(dexPathList, "makeDexElements", ArrayList.class, File.class, ArrayList.class);
|
||||
return (Object[]) makeDexElements.invoke(dexPathList, files, optimizedDirectory, suppressedExceptions);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Locates a given field anywhere in the class inheritance hierarchy.
|
||||
*
|
||||
* @param instance an object to search the field into.
|
||||
* @param name field name
|
||||
* @return a field object
|
||||
* @throws NoSuchFieldException if the field cannot be located
|
||||
*/
|
||||
private static Field findField(Object instance, String name) throws NoSuchFieldException {
|
||||
for (Class<?> clazz = instance.getClass(); clazz != null; clazz = clazz.getSuperclass()) {
|
||||
try {
|
||||
Field field = clazz.getDeclaredField(name);
|
||||
if (!field.isAccessible()) {
|
||||
field.setAccessible(true);
|
||||
}
|
||||
return field;
|
||||
} catch (NoSuchFieldException e) {
|
||||
// ignore and search next
|
||||
}
|
||||
}
|
||||
throw new NoSuchFieldException("Field " + name + " not found in " + instance.getClass());
|
||||
}
|
||||
/**
|
||||
* Locates a given method anywhere in the class inheritance hierarchy.
|
||||
*
|
||||
* @param instance an object to search the method into.
|
||||
* @param name method name
|
||||
* @param parameterTypes method parameter types
|
||||
* @return a method object
|
||||
* @throws NoSuchMethodException if the method cannot be located
|
||||
*/
|
||||
private static Method findMethod(Object instance, String name, Class<?>... parameterTypes) throws NoSuchMethodException {
|
||||
for (Class<?> clazz = instance.getClass(); clazz != null; clazz = clazz.getSuperclass()) {
|
||||
try {
|
||||
Method method = clazz.getDeclaredMethod(name, parameterTypes);
|
||||
if (!method.isAccessible()) {
|
||||
method.setAccessible(true);
|
||||
}
|
||||
return method;
|
||||
} catch (NoSuchMethodException e) {
|
||||
// ignore and search next
|
||||
}
|
||||
}
|
||||
throw new NoSuchMethodException("Method " + name + " with parameters " +
|
||||
Arrays.asList(parameterTypes) + " not found in " + instance.getClass());
|
||||
}
|
||||
/**
|
||||
* Replace the value of a field containing a non null array, by a new array containing the
|
||||
* elements of the original array plus the elements of extraElements.
|
||||
* @param instance the instance whose field is to be modified.
|
||||
* @param fieldName the field to modify.
|
||||
* @param extraElements elements to append at the end of the array.
|
||||
*/
|
||||
private static Object[] originalDex;
|
||||
private static void expandFieldArray(Object instance, String fieldName, Object[] extraElements) throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
|
||||
Field jlrField = findField(instance, fieldName);
|
||||
originalDex = (Object[]) jlrField.get(instance);
|
||||
Object[] combined = (Object[]) Array.newInstance(
|
||||
originalDex.getClass().getComponentType(), originalDex.length + extraElements.length);
|
||||
System.arraycopy(originalDex, 0, combined, 0, originalDex.length);
|
||||
System.arraycopy(extraElements, 0, combined, originalDex.length, extraElements.length);
|
||||
jlrField.set(instance, combined);
|
||||
}
|
||||
|
||||
public static void resetFieldArray(ClassLoader loader) throws Throwable {
|
||||
if (originalDex == null) return;
|
||||
|
||||
Object instance = getDexPathList(loader);
|
||||
|
||||
Field jlrField = findField(instance, "dexElements");
|
||||
jlrField.set(instance, originalDex);
|
||||
|
||||
originalDex = null;
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ public final class Tools
|
||||
}
|
||||
|
||||
private static boolean isClientFirst = false;
|
||||
public static String generate(String version) throws IOException
|
||||
public static String generateLaunchClassPath(String version) throws IOException
|
||||
{
|
||||
StringBuilder libStr = new StringBuilder(); //versnDir + "/" + version + "/" + version + ".jar:";
|
||||
|
||||
@@ -91,8 +91,6 @@ public final class Tools
|
||||
libStr.append(file.getAbsolutePath() + ":");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
libStr.append(Tools.libraries + "/" + Tools.artifactToPath("org.lwjgl", "lwjglboardwalk", "2.9.1") + ":");
|
||||
}
|
||||
|
||||
if (isClientFirst) {
|
||||
|
||||
@@ -0,0 +1,420 @@
|
||||
/*
|
||||
* 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.opengl;
|
||||
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.LWJGLUtil;
|
||||
import org.lwjgl.MemoryUtil;
|
||||
import org.lwjgl.Sys;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.util.*;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
import static org.lwjgl.opengl.GL30.*;
|
||||
import static org.lwjgl.opengl.GL32.*;
|
||||
|
||||
/**
|
||||
* <p/>
|
||||
* Manages GL contexts. Before any rendering is done by a LWJGL system, a call should be made to GLContext.useContext() with a
|
||||
* context. This will ensure that GLContext has an accurate reflection of the current context's capabilities and function
|
||||
* pointers.
|
||||
* <p/>
|
||||
* This class is thread-safe in the sense that multiple threads can safely call all public methods. The class is also
|
||||
* thread-aware in the sense that it tracks a per-thread current context (including capabilities and function pointers).
|
||||
* That way, multiple threads can have multiple contexts current and render to them concurrently.
|
||||
*
|
||||
* @author elias_naur <elias_naur@users.sourceforge.net>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public final class GLContext {
|
||||
|
||||
/** Maps threads to their current context's ContextCapabilities, if any */
|
||||
private static final ThreadLocal<ContextCapabilities> current_capabilities = new ThreadLocal<ContextCapabilities>();
|
||||
|
||||
/**
|
||||
* The getCapabilities() method is a potential hot spot in any LWJGL application, since
|
||||
* it is needed for context capability discovery (e.g. is OpenGL 2.0 supported?), and
|
||||
* for the function pointers of gl functions. However, the 'current_capabilities' ThreadLocal
|
||||
* is (relatively) expensive to look up, and since most OpenGL applications use are single threaded
|
||||
* rendering, the following two is an optimization for this case.
|
||||
* <p/>
|
||||
* ThreadLocals can be thought of as a mapping between threads and values, so the idea
|
||||
* is to use a lock-less cache of mappings between threads and the current ContextCapabilities. The cache
|
||||
* could be any size, but in our case, we want a single sized cache for optimal performance
|
||||
* in the single threaded case.
|
||||
* <p/>
|
||||
* 'fast_path_cache' is the most recent ContextCapabilities (potentially null) and its owner. By
|
||||
* recent I mean the last thread setting the value in setCapabilities(). When getCapabilities()
|
||||
* is called, a check to see if the current is the owner of the ContextCapabilities instance in
|
||||
* fast_path_cache. If so, the instance is returned, if not, some thread has since taken ownership
|
||||
* of the cache entry and the slower current_capabilities ThreadLocal is queried instead.
|
||||
* <p/>
|
||||
* No locks are needed in get/setCapabilities, because even though fast_path_cache can be accessed
|
||||
* from multiple threads at once, we are guaranteed by the JVM spec that its value is always valid.
|
||||
* Furthermore, if the ownership test in getCapabilities() succeeds, the cache entry can only contain
|
||||
* the correct ContextCapabilites (that is, the one from getThreadLocalCapabilites()),
|
||||
* since no other thread can set the owner to anyone else than itself.
|
||||
*/
|
||||
private static CapabilitiesCacheEntry fast_path_cache = new CapabilitiesCacheEntry();
|
||||
|
||||
/**
|
||||
* Simple lock-free cache of CapabilitesEntryCache to avoid allocating more than one
|
||||
* cache entry per thread
|
||||
*/
|
||||
private static final ThreadLocal<CapabilitiesCacheEntry> thread_cache_entries = new ThreadLocal<CapabilitiesCacheEntry>();
|
||||
|
||||
/**
|
||||
* The weak mapping from context Object instances to ContextCapabilities. Used
|
||||
* to avoid recreating a ContextCapabilities every time a context is made current.
|
||||
*/
|
||||
private static final Map<Object, ContextCapabilities> capability_cache = new WeakHashMap<Object, ContextCapabilities>();
|
||||
|
||||
/** Reference count of the native opengl implementation library */
|
||||
private static int gl_ref_count;
|
||||
private static boolean did_auto_load;
|
||||
|
||||
static {
|
||||
Sys.initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current capabilities instance. It contains the flags used
|
||||
* to test for support of a particular extension.
|
||||
*
|
||||
* @return The current capabilities instance.
|
||||
*/
|
||||
public static ContextCapabilities getCapabilities() {
|
||||
ContextCapabilities caps = getCapabilitiesImpl();
|
||||
if ( caps == null )
|
||||
throw new RuntimeException("No OpenGL context found in the current thread.");
|
||||
|
||||
return caps;
|
||||
}
|
||||
|
||||
private static ContextCapabilities getCapabilitiesImpl() {
|
||||
CapabilitiesCacheEntry recent_cache_entry = fast_path_cache;
|
||||
// Check owner of cache entry
|
||||
if ( recent_cache_entry.owner == Thread.currentThread() ) {
|
||||
/* The owner ship test succeeded, so the cache must contain the current ContextCapabilities instance
|
||||
* assert recent_cache_entry.capabilities == getThreadLocalCapabilities();
|
||||
*/
|
||||
return recent_cache_entry.capabilities;
|
||||
} else // Some other thread has written to the cache since, and we fall back to the slower path
|
||||
return getThreadLocalCapabilities();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the capabilities instance associated with the specified context object.
|
||||
*
|
||||
* @param context the context object
|
||||
*
|
||||
* @return the capabilities instance
|
||||
*/
|
||||
static ContextCapabilities getCapabilities(Object context) {
|
||||
return capability_cache.get(context);
|
||||
}
|
||||
|
||||
private static ContextCapabilities getThreadLocalCapabilities() {
|
||||
return current_capabilities.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current capabilities instance. It contains the flags used
|
||||
* to test for support of a particular extension.
|
||||
*
|
||||
* @return The current capabilities instance.
|
||||
*/
|
||||
static void setCapabilities(ContextCapabilities capabilities) {
|
||||
current_capabilities.set(capabilities);
|
||||
|
||||
CapabilitiesCacheEntry thread_cache_entry = thread_cache_entries.get();
|
||||
if ( thread_cache_entry == null ) {
|
||||
thread_cache_entry = new CapabilitiesCacheEntry();
|
||||
thread_cache_entries.set(thread_cache_entry);
|
||||
}
|
||||
thread_cache_entry.owner = Thread.currentThread();
|
||||
thread_cache_entry.capabilities = capabilities;
|
||||
|
||||
fast_path_cache = thread_cache_entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to get a pointer to a named function in the OpenGL library
|
||||
* with a name dependent on the current platform
|
||||
*/
|
||||
static long getPlatformSpecificFunctionAddress(String function_prefix, String[] os_prefixes, String[] os_function_prefixes, String function) {
|
||||
String os_name = AccessController.doPrivileged(new PrivilegedAction<String>() {
|
||||
public String run() {
|
||||
return System.getProperty("os.name");
|
||||
}
|
||||
});
|
||||
for ( int i = 0; i < os_prefixes.length; i++ )
|
||||
if ( os_name.startsWith(os_prefixes[i]) ) {
|
||||
String platform_function_name = function.replaceFirst(function_prefix, os_function_prefixes[i]);
|
||||
long address = getFunctionAddress(platform_function_name);
|
||||
return address;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to get a pointer to a named function with aliases in the OpenGL library.
|
||||
*
|
||||
* @param aliases the function name aliases.
|
||||
*
|
||||
* @return the function pointer address
|
||||
*/
|
||||
static long getFunctionAddress(String[] aliases) {
|
||||
for ( String alias : aliases ) {
|
||||
long address = getFunctionAddress(alias);
|
||||
if ( address != 0 )
|
||||
return address;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Helper method to get a pointer to a named function in the OpenGL library. */
|
||||
static long getFunctionAddress(String name) {
|
||||
ByteBuffer buffer = MemoryUtil.encodeASCII(name);
|
||||
return ngetFunctionAddress(MemoryUtil.getAddress(buffer));
|
||||
}
|
||||
private static native long ngetFunctionAddress(long name);
|
||||
|
||||
/**
|
||||
* Determine which extensions are available and returns the context profile mask. Helper method to ContextCapabilities.
|
||||
*
|
||||
* @param supported_extensions the Set to fill with the available extension names
|
||||
*
|
||||
* @return the context profile mask, will be 0 for any version < 3.2
|
||||
*/
|
||||
static int getSupportedExtensions(final Set<String> supported_extensions) {
|
||||
// Detect OpenGL version first
|
||||
|
||||
/* final */ String version = glGetString(GL_VERSION);
|
||||
|
||||
if (version == null) {
|
||||
// throw new IllegalStateException("glGetString(GL_VERSION) returned null - possibly caused by missing current context.");
|
||||
|
||||
System.err.println("Unable to get real OpenGL version, inserting OpenGL 2.0.");
|
||||
version = "2.0";
|
||||
}
|
||||
|
||||
final StringTokenizer version_tokenizer = new StringTokenizer(version, ". ");
|
||||
final String major_string = version_tokenizer.nextToken();
|
||||
final String minor_string = version_tokenizer.nextToken();
|
||||
|
||||
int majorVersion = 0;
|
||||
int minorVersion = 0;
|
||||
try {
|
||||
majorVersion = Integer.parseInt(major_string);
|
||||
minorVersion = Integer.parseInt(minor_string);
|
||||
} catch (NumberFormatException e) {
|
||||
LWJGLUtil.log("The major and/or minor OpenGL version is malformed: " + e.getMessage());
|
||||
}
|
||||
|
||||
final int[][] GL_VERSIONS = {
|
||||
{ 1, 2, 3, 4, 5 }, // OpenGL 1
|
||||
{ 0, 1 }, // OpenGL 2
|
||||
{ 0, 1, 2, 3 }, // OpenGL 3
|
||||
{ 0, 1, 2, 3, 4 }, // OpenGL 4
|
||||
};
|
||||
|
||||
for ( int major = 1; major <= GL_VERSIONS.length; major++ ) {
|
||||
int[] minors = GL_VERSIONS[major - 1];
|
||||
for ( int minor : minors ) {
|
||||
if ( major < majorVersion || (major == majorVersion && minor <= minorVersion) )
|
||||
supported_extensions.add("OpenGL" + Integer.toString(major) + Integer.toString(minor));
|
||||
}
|
||||
}
|
||||
|
||||
int profileMask = 0;
|
||||
|
||||
if ( majorVersion < 3 ) {
|
||||
// Parse EXTENSIONS string
|
||||
final String extensions_string = glGetString(GL_EXTENSIONS);
|
||||
if ( extensions_string == null )
|
||||
throw new IllegalStateException("glGetString(GL_EXTENSIONS) returned null - is there a context current?");
|
||||
|
||||
final StringTokenizer tokenizer = new StringTokenizer(extensions_string);
|
||||
while ( tokenizer.hasMoreTokens() )
|
||||
supported_extensions.add(tokenizer.nextToken());
|
||||
} else {
|
||||
// Use forward compatible indexed EXTENSIONS
|
||||
final int extensionCount = GL11.glGetInteger(GL_NUM_EXTENSIONS);
|
||||
|
||||
for ( int i = 0; i < extensionCount; i++ )
|
||||
supported_extensions.add(glGetStringi(GL_EXTENSIONS, i));
|
||||
|
||||
// Get the context profile mask for versions >= 3.2
|
||||
if ( 3 < majorVersion || 2 <= minorVersion ) {
|
||||
Util.checkGLError(); // Make sure we have no errors up to this point
|
||||
|
||||
try {
|
||||
profileMask = GL11.glGetInteger(GL_CONTEXT_PROFILE_MASK);
|
||||
// Retrieving GL_CONTEXT_PROFILE_MASK may generate an INVALID_OPERATION error on certain implementations, ignore.
|
||||
// Happens on pre10.1 ATI drivers, when ContextAttribs.withProfileCompatibility is not used
|
||||
Util.checkGLError();
|
||||
} catch (OpenGLException e) {
|
||||
LWJGLUtil.log("Failed to retrieve CONTEXT_PROFILE_MASK");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return profileMask;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to ContextCapabilities. It will try to initialize the native stubs,
|
||||
* and remove the given extension name from the extension set if the initialization fails.
|
||||
*/
|
||||
static void initNativeStubs(final Class<?> extension_class, Set supported_extensions, String ext_name) {
|
||||
resetNativeStubs(extension_class);
|
||||
if ( supported_extensions.contains(ext_name) ) {
|
||||
try {
|
||||
AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
|
||||
public Object run() throws Exception {
|
||||
Method init_stubs_method = extension_class.getDeclaredMethod("initNativeStubs");
|
||||
init_stubs_method.invoke(null);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
LWJGLUtil.log("Failed to initialize extension " + extension_class + " - exception: " + e);
|
||||
supported_extensions.remove(ext_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a GL context the current LWJGL context by loading GL function pointers. The context must be current before a call to
|
||||
* this method! Instead it simply ensures that the current context is reflected accurately by GLContext's extension caps and
|
||||
* function pointers. Use useContext(null) when no context is active. <p>If the context is the same as last time, then this is
|
||||
* a no-op. <p>If the context has not been encountered before it will be fully initialized from scratch. Otherwise a cached set
|
||||
* of caps and function pointers will be used. <p>The reference to the context is held in a weak reference; therefore if no
|
||||
* strong reference exists to the GL context it will automatically be forgotten by the VM at an indeterminate point in the
|
||||
* future, freeing up a little RAM.
|
||||
*
|
||||
* @param context The context object, which uniquely identifies a GL context. If context is null, the native stubs are
|
||||
* unloaded.
|
||||
*
|
||||
* @throws LWJGLException if context non-null, and the gl library can't be loaded or the basic GL11 functions can't be loaded
|
||||
*/
|
||||
public static synchronized void useContext(Object context) throws LWJGLException {
|
||||
useContext(context, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a GL context the current LWJGL context by loading GL function pointers. The context must be current before a call to
|
||||
* this method! Instead it simply ensures that the current context is reflected accurately by GLContext's extension caps and
|
||||
* function pointers. Use useContext(null) when no context is active. <p>If the context is the same as last time, then this is
|
||||
* a no-op. <p>If the context has not been encountered before it will be fully initialized from scratch. Otherwise a cached set
|
||||
* of caps and function pointers will be used. <p>The reference to the context is held in a weak reference; therefore if no
|
||||
* strong reference exists to the GL context it will automatically be forgotten by the VM at an indeterminate point in the
|
||||
* future, freeing up a little RAM.
|
||||
* <p>If forwardCompatible is true, function pointers of deprecated GL11-GL21 functionality will not be loaded. Calling a deprecated
|
||||
* function using the specified context will result in an <code>IllegalStateException</code>.
|
||||
*
|
||||
* @param context The context object, which uniquely identifies a GL context. If context is null, the native stubs are
|
||||
* unloaded.
|
||||
* @param forwardCompatible If the context is a forward compatible context (does not expose deprecated functionality, see XGL_ARB_create_context)
|
||||
*
|
||||
* @throws LWJGLException if context non-null, and the gl library can't be loaded or the basic GL11 functions can't be loaded
|
||||
*/
|
||||
public static synchronized void useContext(Object context, boolean forwardCompatible) throws LWJGLException {
|
||||
if ( context == null ) {
|
||||
ContextCapabilities.unloadAllStubs();
|
||||
setCapabilities(null);
|
||||
if ( did_auto_load )
|
||||
unloadOpenGLLibrary();
|
||||
return;
|
||||
}
|
||||
if ( gl_ref_count == 0 ) {
|
||||
loadOpenGLLibrary();
|
||||
did_auto_load = true;
|
||||
}
|
||||
try {
|
||||
ContextCapabilities capabilities = capability_cache.get(context);
|
||||
if ( capabilities == null ) {
|
||||
/*
|
||||
* The capabilities object registers itself as current. This behaviour is caused
|
||||
* by a chicken-and-egg situation where the constructor needs to call GL functions
|
||||
* as part of its capability discovery, but GL functions cannot be called before
|
||||
* a capabilities object has been set.
|
||||
*/
|
||||
new ContextCapabilities(forwardCompatible);
|
||||
capability_cache.put(context, getCapabilities());
|
||||
} else
|
||||
setCapabilities(capabilities);
|
||||
} catch (LWJGLException e) {
|
||||
if ( did_auto_load )
|
||||
unloadOpenGLLibrary();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/** If the OpenGL reference count is 0, the library is loaded. The reference count is then incremented. */
|
||||
public static synchronized void loadOpenGLLibrary() throws LWJGLException {
|
||||
if ( gl_ref_count == 0 )
|
||||
nLoadOpenGLLibrary();
|
||||
gl_ref_count++;
|
||||
}
|
||||
|
||||
private static native void nLoadOpenGLLibrary() throws LWJGLException;
|
||||
|
||||
/** The OpenGL library reference count is decremented, and if it reaches 0, the library is unloaded. */
|
||||
public static synchronized void unloadOpenGLLibrary() {
|
||||
gl_ref_count--;
|
||||
/*
|
||||
* Unload the native OpenGL library unless we're on linux, since
|
||||
* some drivers (NVIDIA proprietary) crash on exit when unloading the library.
|
||||
*/
|
||||
if ( gl_ref_count == 0 && LWJGLUtil.getPlatform() != LWJGLUtil.PLATFORM_LINUX )
|
||||
nUnloadOpenGLLibrary();
|
||||
}
|
||||
|
||||
private static native void nUnloadOpenGLLibrary();
|
||||
|
||||
/** Native method to clear native stub bindings */
|
||||
static native void resetNativeStubs(Class clazz);
|
||||
|
||||
private static final class CapabilitiesCacheEntry {
|
||||
|
||||
Thread owner;
|
||||
ContextCapabilities capabilities;
|
||||
}
|
||||
}
|
||||
@@ -309,7 +309,7 @@
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="right"
|
||||
android:fitsSystemWindows="true"
|
||||
android:fitsSystemWindows="false"
|
||||
app:menu="@menu/menu_runopt"
|
||||
android:id="@+id/main_navigation_view"/>
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
<string name="alerttitle_installoptifine">Select OptiFine jar file</string>
|
||||
|
||||
<!-- Error messages -->
|
||||
<string name="error_fatal">Fatal error</string>
|
||||
<string name="error_fatal">PojavLauncher has unexpectedly crashed</string>
|
||||
<string name="error_checklog">Error! Please check the log below: %s</string>
|
||||
<string name="error_no_version">No version!</string>
|
||||
<string name="error_load_version">Unable to load version %s</string>
|
||||
@@ -118,6 +118,7 @@
|
||||
<string name="global_load">Load</string>
|
||||
<string name="global_name">Name</string>
|
||||
<string name="global_remove">Remove</string>
|
||||
<string name="global_restart">Restart</string>
|
||||
<string name="global_save">Save</string>
|
||||
<string name="global_error_field_empty">This field can\'t be empty</string>
|
||||
|
||||
|
||||
@@ -6,20 +6,14 @@
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="android:windowContentOverlay">@null</item>
|
||||
<item name="android:windowFullscreen">true</item>
|
||||
<item name="android:windowTranslucentNavigation">true</item>
|
||||
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
|
||||
</style>
|
||||
|
||||
<style name="RunTheme" parent="@style/Theme.AppCompat.NoActionBar">
|
||||
<item name="windowNoTitle">true</item>
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="android:windowContentOverlay">@null</item>
|
||||
<item name="android:windowFullscreen">true</item>
|
||||
<style name="AlertTheme" parent="@style/AppTheme">
|
||||
</style>
|
||||
|
||||
<style name="AlertTheme" parent="@android:style/Theme.Material">
|
||||
</style>
|
||||
|
||||
<style name="MenuDialog" parent="@android:style/Theme.Material">
|
||||
<style name="MenuDialog" parent="@style/AppTheme">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
|
||||
@@ -28,18 +22,17 @@
|
||||
<item name="android:windowContentOverlay">@null</item>
|
||||
<item name="android:windowAnimationStyle">@style/MenuDialogAnimation</item>
|
||||
<item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
|
||||
<item name="android:windowTranslucentNavigation">true</item>
|
||||
</style>
|
||||
<style name="AppTheme.Fullscreen" parent="AppTheme">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
|
||||
<style name="MenuDialogAnimation">
|
||||
<item name="android:windowEnterAnimation">@anim/translate_left_side</item>
|
||||
<item name="android:windowExitAnimation">@anim/translate_right_side</item>
|
||||
<item name="android:windowTranslucentNavigation">true</item>
|
||||
</style>
|
||||
|
||||
<style name="SpinnerChangeLanguage">
|
||||
<item name="android:windowTranslucentNavigation">true</item>
|
||||
<item name="android:background">@drawable/spinner_change_language</item>
|
||||
</style>
|
||||
</resources>
|
||||
Reference in new issue
Block a user