fixed #104: loading of multiple .love files

This commit is contained in:
fysx
2015-02-18 10:33:54 +01:00
parent d6f1d8bd70
commit 168357e1ad
4 changed files with 89 additions and 56 deletions
+18 -15
View File
@@ -75,23 +75,26 @@ const char* getSelectedGameFile()
{
static const char *path = NULL;
if (!path) {
JNIEnv *env = (JNIEnv*) SDL_AndroidGetJNIEnv();
jclass activity = env->FindClass("org/love2d/android/GameActivity");
jmethodID getGamePath = env->GetStaticMethodID(activity, "getGamePath", "()Ljava/lang/String;");
jstring gamePath = (jstring) env->CallStaticObjectMethod(activity, getGamePath);
const char *utf = env->GetStringUTFChars(gamePath, 0);
if (utf)
{
path = SDL_strdup(utf);
env->ReleaseStringUTFChars(gamePath, utf);
}
env->DeleteLocalRef (gamePath);
env->DeleteLocalRef (activity);
if (path) {
delete path;
path = NULL;
}
JNIEnv *env = (JNIEnv*) SDL_AndroidGetJNIEnv();
jclass activity = env->FindClass("org/love2d/android/GameActivity");
jmethodID getGamePath = env->GetStaticMethodID(activity, "getGamePath", "()Ljava/lang/String;");
jstring gamePath = (jstring) env->CallStaticObjectMethod(activity, getGamePath);
const char *utf = env->GetStringUTFChars(gamePath, 0);
if (utf)
{
path = SDL_strdup(utf);
env->ReleaseStringUTFChars(gamePath, utf);
}
env->DeleteLocalRef (gamePath);
env->DeleteLocalRef (activity);
return path;
}