2017-01-10 12:43:06 +00:00
|
|
|
package fishrungames.doublehitballs;
|
|
|
|
|
|
|
|
import fishrungames.salmonengineandroid.EngineWrapper;
|
|
|
|
//Deprecated
|
|
|
|
//import fishrungames.doublehitballs.R;
|
|
|
|
|
|
|
|
import android.app.Activity;
|
|
|
|
import android.content.pm.ApplicationInfo;
|
|
|
|
import android.content.pm.PackageManager;
|
|
|
|
import android.content.pm.PackageManager.NameNotFoundException;
|
|
|
|
import android.os.Bundle;
|
2018-11-29 03:37:06 +00:00
|
|
|
import android.util.Log;
|
2017-01-10 12:43:06 +00:00
|
|
|
import android.view.KeyEvent;
|
|
|
|
import android.view.MotionEvent;
|
|
|
|
|
|
|
|
//Deprecated
|
|
|
|
//import java.lang.reflect.Field;
|
|
|
|
|
|
|
|
|
|
|
|
public class GL2JNIActivity extends Activity
|
|
|
|
{
|
2018-08-07 18:01:35 +00:00
|
|
|
|
|
|
|
private static GL2JNIActivity instance;
|
2017-01-10 12:43:06 +00:00
|
|
|
|
|
|
|
GLView mView;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle icicle)
|
|
|
|
{
|
|
|
|
super.onCreate(icicle);
|
2018-08-07 18:01:35 +00:00
|
|
|
|
|
|
|
instance = this;
|
|
|
|
|
2017-01-10 12:43:06 +00:00
|
|
|
EngineWrapper.LoadSalmonEngineLibrary();
|
|
|
|
EngineWrapper.SetActivityInstance(this);
|
|
|
|
EngineWrapper.SetupEnviroment();
|
2018-10-04 21:16:10 +00:00
|
|
|
JniWrapper.SetJavaVM();
|
|
|
|
JniWrapper.SetContext(this);
|
2017-01-10 12:43:06 +00:00
|
|
|
|
|
|
|
String apkFilePath = null;
|
|
|
|
ApplicationInfo appInfo = null;
|
|
|
|
PackageManager packMgmr = this.getPackageManager();
|
|
|
|
try {
|
|
|
|
appInfo = packMgmr.getApplicationInfo("fishrungames.DoubleHitBalls", 0);
|
|
|
|
} catch (NameNotFoundException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
throw new RuntimeException("Unable to locate assets, aborting...");
|
|
|
|
}
|
|
|
|
apkFilePath = appInfo.sourceDir;
|
|
|
|
|
|
|
|
EngineWrapper.SetupApkFilePath(apkFilePath);
|
|
|
|
|
|
|
|
mView = new GLView(getApplication());
|
|
|
|
|
|
|
|
setContentView(mView);
|
|
|
|
|
|
|
|
EngineWrapper.SetView(mView);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onPause()
|
|
|
|
{
|
2018-10-15 12:29:14 +00:00
|
|
|
//EngineWrapper.CallDestroy();
|
2017-01-10 12:43:06 +00:00
|
|
|
super.onPause();
|
|
|
|
mView.onPause();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onResume()
|
|
|
|
{
|
|
|
|
super.onResume();
|
|
|
|
mView.onResume();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onStop()
|
|
|
|
{
|
|
|
|
super.onStop();
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean onTouchEvent (MotionEvent event)
|
|
|
|
{
|
|
|
|
EngineWrapper.ProcessTouchEvent(event);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean onKeyDown(int keyCode, KeyEvent event)
|
|
|
|
{
|
|
|
|
EngineWrapper.ProcessKeyDown(keyCode, event);
|
|
|
|
return super.onKeyDown(keyCode, event);
|
|
|
|
}
|
2018-08-07 18:01:35 +00:00
|
|
|
|
|
|
|
public static GL2JNIActivity getInstance() {
|
2018-08-07 18:13:18 +00:00
|
|
|
if (instance == null) {
|
|
|
|
throw new RuntimeException("error GL2JNIActivity getInstance() - you are trying to get activity instance when it is not created or already destroyed");
|
|
|
|
}
|
2018-08-07 18:01:35 +00:00
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
2017-01-10 12:43:06 +00:00
|
|
|
}
|