Fix desktop game packaging issue;

Accidentally hardcoded it to "assets" when updating Android.
This commit is contained in:
bjorn 2020-07-29 16:30:14 -06:00
parent 826fc098bc
commit 4160743b77
7 changed files with 13 additions and 7 deletions

View File

@ -68,7 +68,7 @@ size_t lovrPlatformGetHomeDirectory(char* buffer, size_t size);
size_t lovrPlatformGetDataDirectory(char* buffer, size_t size);
size_t lovrPlatformGetWorkingDirectory(char* buffer, size_t size);
size_t lovrPlatformGetExecutablePath(char* buffer, size_t size);
size_t lovrPlatformGetBundlePath(char* buffer, size_t size);
size_t lovrPlatformGetBundlePath(char* buffer, size_t size, const char** root);
bool lovrPlatformCreateWindow(WindowFlags* flags);
bool lovrPlatformHasWindow(void);
void lovrPlatformGetWindowSize(int* width, int* height);

View File

@ -159,7 +159,7 @@ size_t lovrPlatformGetExecutablePath(char* buffer, size_t size) {
}
}
size_t lovrPlatformGetBundlePath(char* buffer, size_t size) {
size_t lovrPlatformGetBundlePath(char* buffer, size_t size, const char** root) {
jobject activity = state.app->activity->clazz;
jclass class = (*state.jni)->GetObjectClass(state.jni, activity);
jmethodID getPackageCodePath = (*state.jni)->GetMethodID(state.jni, class, "getPackageCodePath", "()Ljava/lang/String;");
@ -178,6 +178,7 @@ size_t lovrPlatformGetBundlePath(char* buffer, size_t size) {
if (length >= size) return 0;
memcpy(buffer, path, length);
buffer[length] = '\0';
*root = "/assets";
return length;
}

View File

@ -110,6 +110,7 @@ size_t lovrPlatformGetExecutablePath(char* buffer, size_t size) {
}
}
size_t lovrPlatformGetBundlePath(char* buffer, size_t size) {
size_t lovrPlatformGetBundlePath(char* buffer, size_t size, const char** root) {
*root = NULL;
return lovrPlatformGetExecutablePath(buffer, size);
}

View File

@ -98,7 +98,7 @@ size_t lovrPlatformGetExecutablePath(char* buffer, size_t size) {
return _NSGetExecutablePath(buffer, &size32) ? 0 : size32;
}
size_t lovrPlatformGetBundlePath(char* buffer, size_t size) {
size_t lovrPlatformGetBundlePath(char* buffer, size_t size, const char** root) {
id extension = ((id(*)(Class, SEL, char*)) objc_msgSend)(objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), "lovr");
id bundle = ((id(*)(Class, SEL)) objc_msgSend)(objc_getClass("NSBundle"), sel_registerName("mainBundle"));
id path = ((id(*)(id, SEL, char*, id)) objc_msgSend)(bundle, sel_registerName("pathForResource:ofType:"), nil, extension);
@ -118,5 +118,6 @@ size_t lovrPlatformGetBundlePath(char* buffer, size_t size) {
memcpy(buffer, cpath, length);
buffer[length] = '\0';
*root = NULL;
return length;
}

View File

@ -61,6 +61,7 @@ size_t lovrPlatformGetExecutablePath(char* buffer, size_t size) {
return 0;
}
size_t lovrPlatformGetBundlePath(char* buffer, size_t size) {
size_t lovrPlatformGetBundlePath(char* buffer, size_t size, const char** root) {
*root = NULL;
return 0;
}

View File

@ -95,6 +95,7 @@ size_t lovrPlatformGetExecutablePath(char* buffer, size_t size) {
return 0;
}
size_t lovrPlatformGetBundlePath(char* buffer, size_t size) {
size_t lovrPlatformGetBundlePath(char* buffer, size_t size, const char** root) {
*root = NULL;
return lovrPlatformGetExecutablePath(buffer, size);
}

View File

@ -119,7 +119,8 @@ bool lovrFilesystemInit(const char* argExe, const char* argGame, const char* arg
lovrFilesystemSetCRequirePath("??;lua_modules/??;deps/??");
// First, try to mount a bundled archive
if (lovrPlatformGetBundlePath(state.source, LOVR_PATH_MAX) && lovrFilesystemMount(state.source, NULL, true, "/assets")) {
const char* root = NULL;
if (lovrPlatformGetBundlePath(state.source, LOVR_PATH_MAX, &root) && lovrFilesystemMount(state.source, NULL, true, root)) {
state.fused = true;
return true;
}