From 945823ca3050e82ca8d88b3616f428de3e120b7d Mon Sep 17 00:00:00 2001 From: leo60228 Date: Tue, 5 Sep 2023 14:21:57 -0400 Subject: [PATCH] Build and mount repo.zip with fonts/ and lang/ --- .../VVVVVV-android/app/build.gradle | 26 +++++++++++++++++++ desktop_version/src/FileSystemUtils.cpp | 24 +++++++++++------ 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/desktop_version/VVVVVV-android/app/build.gradle b/desktop_version/VVVVVV-android/app/build.gradle index 67a24b83..354a6e26 100644 --- a/desktop_version/VVVVVV-android/app/build.gradle +++ b/desktop_version/VVVVVV-android/app/build.gradle @@ -68,6 +68,32 @@ android { enable true } } + + sourceSets { + main { + assets { + srcDir layout.buildDirectory.dir("generated/main/assets") + } + } + } +} + +def zipRepoAssetsTask = tasks.register("zipRepoAssets", Zip) { + from('../../fonts') { spec -> + spec.into('graphics') + } + from('../../lang') { spec -> + spec.into('lang') + } + archiveFileName.set('repo.zip') + destinationDirectory.value(layout.buildDirectory.dir("generated/main/assets")) +} + +project.android.applicationVariants.configureEach { variant -> + def compressAssetsTask = project.tasks.named("merge${variant.name.capitalize()}Assets") + compressAssetsTask.configure { task -> + task.dependsOn zipRepoAssetsTask + } } dependencies { diff --git a/desktop_version/src/FileSystemUtils.cpp b/desktop_version/src/FileSystemUtils.cpp index 7d053af5..6a21468f 100644 --- a/desktop_version/src/FileSystemUtils.cpp +++ b/desktop_version/src/FileSystemUtils.cpp @@ -266,12 +266,6 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath, char* langD basePath = SDL_strdup("./"); } - doesLangDirExist = mount_pre_datazip(mainLangDir, "lang", "lang/", langDir); - vlog_info("Languages directory: %s", mainLangDir); - - doesFontsDirExist = mount_pre_datazip(NULL, "fonts", "graphics/", fontsDir); - - /* Mount the stock content last */ #ifdef __ANDROID__ // This is kind of a mess, but that's not really solvable unless we expect the user to download the data.zip manually. if (!PHYSFS_mount(PHYSFS_getBaseDir(), "/apk", 1)) @@ -279,9 +273,23 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath, char* langD vlog_error("Failed to mount apk!"); return 0; } - PHYSFS_File* zip = PHYSFS_openRead("/apk/assets/data.zip"); - if (!zip || !PHYSFS_mountHandle(zip, "data.zip", NULL, 1)) + + PHYSFS_File* repoZip = PHYSFS_openRead("/apk/assets/repo.zip"); + if (repoZip && PHYSFS_mountHandle(repoZip, "repo.zip", NULL, 1)) + { + doesLangDirExist = true; + doesFontsDirExist = true; + } + + PHYSFS_File* dataZip = PHYSFS_openRead("/apk/assets/data.zip"); + if (!dataZip || !PHYSFS_mountHandle(dataZip, "data.zip", NULL, 1)) #else + doesLangDirExist = mount_pre_datazip(mainLangDir, "lang", "lang/", langDir); + vlog_info("Languages directory: %s", mainLangDir); + + doesFontsDirExist = mount_pre_datazip(NULL, "fonts", "graphics/", fontsDir); + + /* Mount the stock content last */ if (assetsPath) { SDL_strlcpy(output, assetsPath, sizeof(output));