2013-01-23 20:14:11 +00:00
|
|
|
#include "android_api.h"
|
|
|
|
|
|
|
|
#include "main_code.h"
|
|
|
|
#include "boost\thread.hpp"
|
|
|
|
|
2013-02-05 20:44:27 +00:00
|
|
|
boost::shared_ptr<TMyApplication> App;
|
2013-01-23 20:14:11 +00:00
|
|
|
|
|
|
|
boost::mutex m;
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height)
|
|
|
|
{
|
|
|
|
|
|
|
|
m.lock();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
|
2013-02-05 20:44:27 +00:00
|
|
|
CreateEngine();
|
|
|
|
|
|
|
|
App = boost::shared_ptr<TMyApplication>(new TMyApplication);
|
|
|
|
|
|
|
|
App->OuterInit(width, height, 320.f, 480.f);
|
2013-01-23 20:14:11 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
{
|
2013-02-05 20:44:27 +00:00
|
|
|
m.lock();
|
2013-01-23 20:14:11 +00:00
|
|
|
try
|
|
|
|
{
|
2013-02-05 20:44:27 +00:00
|
|
|
|
2013-01-23 20:14:11 +00:00
|
|
|
App->OuterDraw();
|
|
|
|
App->OuterUpdate(dt);
|
2013-02-05 20:44:27 +00:00
|
|
|
|
2013-01-23 20:14:11 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
m.unlock();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT int JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_IsInited(JNIEnv * env, jobject obj)
|
|
|
|
{
|
|
|
|
|
2013-02-05 20:44:27 +00:00
|
|
|
return 0;
|
2013-01-23 20:14:11 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Destroy(JNIEnv * env, jobject obj)
|
|
|
|
{
|
2013-02-05 20:44:27 +00:00
|
|
|
m.lock();
|
2013-01-23 20:14:11 +00:00
|
|
|
try
|
|
|
|
{
|
2013-02-05 20:44:27 +00:00
|
|
|
|
2013-01-23 20:14:11 +00:00
|
|
|
App->OuterDeinit();
|
2013-02-05 20:44:27 +00:00
|
|
|
|
|
|
|
delete App;
|
|
|
|
|
|
|
|
App = NULL;
|
|
|
|
|
|
|
|
DestroyEngine();
|
2013-01-23 20:14:11 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
m.unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapDown(JNIEnv * env, jobject obj, float x, float y, long time)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2013-01-27 21:48:57 +00:00
|
|
|
App->OuterOnTapDown(vec2(x,y));
|
2013-01-23 20:14:11 +00:00
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapUp(JNIEnv * env, jobject obj, float x, float y, long time)
|
|
|
|
{
|
2013-01-27 21:48:57 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
App->OuterOnTapUp(vec2(x,y));
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapUpAfterShift(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
App->OuterOnTapUpAfterShift(vec2(x,y));
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
throw;
|
|
|
|
}
|
2013-01-23 20:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapMove(JNIEnv * env, jobject obj, float x, float y, long time)
|
|
|
|
{
|
2013-01-29 19:20:42 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
App->OuterOnMove(vec2(x,y));
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
throw;
|
|
|
|
}
|
2013-01-23 20:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2013-01-29 19:20:42 +00:00
|
|
|
|
2013-01-27 21:48:57 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
App->OuterOnMove(vec2(distanceX,distanceY));
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
throw;
|
|
|
|
}
|
2013-01-23 20:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnKeyPress(JNIEnv * env, jobject obj, jint keyCode)
|
|
|
|
{
|
|
|
|
//App->OnKeyPress(keyCode);
|
|
|
|
}
|