catch up
This commit is contained in:
parent
87f4d81238
commit
287ab26da1
@ -1,128 +1,10 @@
|
|||||||
#include "android_api.h"
|
#include "android_api.h"
|
||||||
|
|
||||||
#include "main_code.h"
|
#include "main_code.h"
|
||||||
#include "boost\thread.hpp"
|
|
||||||
|
|
||||||
boost::shared_ptr<TMyApplication> App(new TMyApplication);
|
|
||||||
|
|
||||||
boost::mutex m;
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height)
|
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height)
|
||||||
{
|
{
|
||||||
|
JniInitApp<TMyApplication>(width, height, 480.f, 320.f);
|
||||||
m.lock();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (App->IsInited())
|
|
||||||
{
|
|
||||||
App->OuterDeinit(); //Clean up what is left at previous launch (if applicable)
|
|
||||||
}
|
|
||||||
|
|
||||||
App->OuterInit(width, height, 480.f, 320.f);
|
|
||||||
|
|
||||||
App->Inited = true;
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
m.unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_StopSounds(JNIEnv * env, jobject obj)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Update(JNIEnv * env, jobject obj, long dt)
|
|
||||||
{
|
|
||||||
m.lock();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (App->IsInited())
|
|
||||||
{
|
|
||||||
App->OuterDraw();
|
|
||||||
App->OuterUpdate(dt);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
m.unlock();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT int JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_IsInited(JNIEnv * env, jobject obj)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (App->IsInited())
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Destroy(JNIEnv * env, jobject obj)
|
|
||||||
{
|
|
||||||
m.lock();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (App->IsInited())
|
|
||||||
{
|
|
||||||
App->OuterDeinit();
|
|
||||||
App->Inited = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
m.unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapDown(JNIEnv * env, jobject obj, float x, float y, long time)
|
|
||||||
{
|
|
||||||
m.lock();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Renderer->MoveDist(1.0f);
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
m.unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapUp(JNIEnv * env, jobject obj, float x, float y, long time)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapMove(JNIEnv * env, jobject obj, float x, float y, long time)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnFling(JNIEnv * env, jobject obj, jfloat velocityX, jfloat velocityY, long time)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnScroll(JNIEnv * env, jobject obj, jfloat distanceX, jfloat distanceY, long time)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnKeyPress(JNIEnv * env, jobject obj, jint keyCode)
|
|
||||||
{
|
|
||||||
//App->OnKeyPress(keyCode);
|
|
||||||
}
|
|
||||||
|
@ -12,21 +12,13 @@
|
|||||||
|
|
||||||
#include "main_code.h"
|
#include "main_code.h"
|
||||||
|
|
||||||
|
#include "include/Engine.h"
|
||||||
|
|
||||||
using namespace SE;
|
using namespace SE;
|
||||||
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height);
|
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height);
|
||||||
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_StopSounds(JNIEnv * env, jobject obj);
|
|
||||||
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Update(JNIEnv * env, jobject obj, long dt);
|
|
||||||
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Destroy(JNIEnv * env, jobject obj);
|
|
||||||
JNIEXPORT int JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_IsInited(JNIEnv * env, jobject obj);
|
|
||||||
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapDown(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time);
|
|
||||||
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapUp(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time);
|
|
||||||
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapMove(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time);
|
|
||||||
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnFling(JNIEnv * env, jobject obj, jfloat velocityX, jfloat velocityY, long time);
|
|
||||||
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnScroll(JNIEnv * env, jobject obj, jfloat distanceX, jfloat distanceY, long time);
|
|
||||||
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnKeyPress(JNIEnv * env, jobject obj, jint keyCode);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import javax.microedition.khronos.egl.EGLConfig;
|
|||||||
import javax.microedition.khronos.opengles.GL10;
|
import javax.microedition.khronos.opengles.GL10;
|
||||||
|
|
||||||
import fishrungames.engine.GLViewAncestor;
|
import fishrungames.engine.GLViewAncestor;
|
||||||
|
import fishrungames.engine.EngineWrapper;
|
||||||
|
|
||||||
class GLView extends GLViewAncestor
|
class GLView extends GLViewAncestor
|
||||||
{
|
{
|
||||||
@ -49,7 +50,7 @@ class GLView extends GLViewAncestor
|
|||||||
|
|
||||||
long currentTimeStamp = c.getTimeInMillis();
|
long currentTimeStamp = c.getTimeInMillis();
|
||||||
|
|
||||||
JniWrapper.Update(currentTimeStamp - lastTimeStamp);
|
EngineWrapper.Update(currentTimeStamp - lastTimeStamp);
|
||||||
|
|
||||||
lastTimeStamp = currentTimeStamp;
|
lastTimeStamp = currentTimeStamp;
|
||||||
}
|
}
|
||||||
|
@ -8,16 +8,5 @@ public class JniWrapper
|
|||||||
|
|
||||||
|
|
||||||
public static native void Init(int width, int height);
|
public static native void Init(int width, int height);
|
||||||
public static native void Update(long dt);
|
|
||||||
public static native void StopSounds();
|
|
||||||
public static native void Destroy();
|
|
||||||
public static native int IsInited();
|
|
||||||
public static native void OnTapDown(float x, float y, long time);
|
|
||||||
public static native void OnTapUp(float x, float y, long time);
|
|
||||||
public static native void OnTapMove(float x, float y, long time);
|
|
||||||
|
|
||||||
public static native void OnFling(float velocityX, float velocityY, long time);
|
|
||||||
public static native void OnScroll(float distanceX, float distanceY, long time);
|
|
||||||
|
|
||||||
public static native void OnKeyPress(int keyCode);
|
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package fishrungames.salmonjnitemplate;
|
package fishrungames.salmonjnitemplate;
|
||||||
|
|
||||||
import fishrungames.engine.FileWrapper;
|
import fishrungames.engine.EngineWrapper;
|
||||||
|
|
||||||
//Deprecated
|
//Deprecated
|
||||||
//import fishrungames.androidjnitemplate.R;
|
//import fishrungames.androidjnitemplate.R;
|
||||||
@ -15,19 +15,7 @@ import android.view.GestureDetector;
|
|||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.GestureDetector.SimpleOnGestureListener;
|
import android.view.GestureDetector.SimpleOnGestureListener;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
/*
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.content.res.XmlResourceParser;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.util.Xml;
|
|
||||||
import android.inputmethodservice.Keyboard;
|
|
||||||
import android.inputmethodservice.KeyboardView;
|
|
||||||
import android.view.ViewGroup.LayoutParams;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
*/
|
|
||||||
|
|
||||||
//Deprecated
|
|
||||||
//import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
|
|
||||||
public class MainActivity extends Activity
|
public class MainActivity extends Activity
|
||||||
@ -35,42 +23,16 @@ public class MainActivity extends Activity
|
|||||||
|
|
||||||
GLView mView;
|
GLView mView;
|
||||||
|
|
||||||
boolean IsScrolling = false;
|
|
||||||
|
|
||||||
private GestureDetector gestureDetector;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle icicle)
|
protected void onCreate(Bundle icicle)
|
||||||
{
|
{
|
||||||
|
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
|
|
||||||
gestureDetector = new GestureDetector(new MyGestureListener());
|
EngineWrapper.LoadSalmonEngineLibrary();
|
||||||
|
|
||||||
FileWrapper.LoadSalmonEngineLibrary();
|
EngineWrapper.SetActivityInstance(this);
|
||||||
|
EngineWrapper.SetupEnviroment();
|
||||||
FileWrapper.SetActivityInstance(this);
|
|
||||||
FileWrapper.SetupEnviroment();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Deprecated
|
|
||||||
try
|
|
||||||
{
|
|
||||||
for (Field f : R.raw.class.getFields())
|
|
||||||
{
|
|
||||||
FileWrapper.AddToFileMap(f.getName(), f.getInt(null));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} catch (IllegalArgumentException e)
|
|
||||||
{
|
|
||||||
FileWrapper.ConsoleOut("IllegalArgumentException\n");
|
|
||||||
onStop();
|
|
||||||
} catch (IllegalAccessException e)
|
|
||||||
{
|
|
||||||
FileWrapper.ConsoleOut("IllegalAccessException\n");
|
|
||||||
onStop();
|
|
||||||
}*/
|
|
||||||
|
|
||||||
String apkFilePath = null;
|
String apkFilePath = null;
|
||||||
ApplicationInfo appInfo = null;
|
ApplicationInfo appInfo = null;
|
||||||
@ -84,7 +46,7 @@ public class MainActivity extends Activity
|
|||||||
}
|
}
|
||||||
apkFilePath = appInfo.sourceDir;
|
apkFilePath = appInfo.sourceDir;
|
||||||
|
|
||||||
FileWrapper.SetupApkFilePath(apkFilePath);
|
EngineWrapper.SetupApkFilePath(apkFilePath);
|
||||||
|
|
||||||
mView = new GLView(getApplication());
|
mView = new GLView(getApplication());
|
||||||
|
|
||||||
@ -95,7 +57,7 @@ public class MainActivity extends Activity
|
|||||||
@Override
|
@Override
|
||||||
protected void onPause()
|
protected void onPause()
|
||||||
{
|
{
|
||||||
JniWrapper.Destroy();
|
EngineWrapper.Destroy();
|
||||||
super.onPause();
|
super.onPause();
|
||||||
mView.onPause();
|
mView.onPause();
|
||||||
}
|
}
|
||||||
@ -117,75 +79,15 @@ public class MainActivity extends Activity
|
|||||||
|
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event)
|
public boolean onKeyDown(int keyCode, KeyEvent event)
|
||||||
{
|
{
|
||||||
int ascii_keycode = keyCode;
|
|
||||||
|
|
||||||
if (keyCode == KeyEvent.KEYCODE_DEL)
|
EngineWrapper.ProcessKeyDown(keyCode, event);
|
||||||
{
|
|
||||||
ascii_keycode = 8; //Hack - getUnicodeChar does not recognize backspace
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ascii_keycode = event.getUnicodeChar();
|
|
||||||
}
|
|
||||||
|
|
||||||
JniWrapper.OnKeyPress(ascii_keycode);
|
|
||||||
return super.onKeyDown(keyCode, event);
|
return super.onKeyDown(keyCode, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onTouchEvent(MotionEvent event)
|
public boolean onTouchEvent(MotionEvent event)
|
||||||
{
|
{
|
||||||
if (gestureDetector.onTouchEvent(event))
|
EngineWrapper.ProcessTouchEvent(event);
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getAction() == MotionEvent.ACTION_UP)
|
|
||||||
{
|
|
||||||
float x = event.getX();
|
|
||||||
float y = (float) mView.getHeight() - event.getY();
|
|
||||||
|
|
||||||
if (IsScrolling)
|
|
||||||
{
|
|
||||||
IsScrolling = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
JniWrapper.OnTapUp(x, y, event.getEventTime());
|
|
||||||
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
class MyGestureListener extends SimpleOnGestureListener
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
|
|
||||||
float velocityY)
|
|
||||||
{
|
|
||||||
JniWrapper.OnFling(velocityX, velocityY, e2.getEventTime());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean onScroll(MotionEvent e1, MotionEvent e2,
|
|
||||||
float distanceX, float distanceY)
|
|
||||||
{
|
|
||||||
|
|
||||||
JniWrapper.OnScroll(distanceX, distanceY, e2.getEventTime());
|
|
||||||
IsScrolling = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean onDown(MotionEvent event)
|
|
||||||
{
|
|
||||||
|
|
||||||
float x = event.getX();
|
|
||||||
float y = (float) mView.getHeight() - event.getY();
|
|
||||||
|
|
||||||
JniWrapper.OnTapDown(x, y, event.getEventTime());
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user