Data like brushes, starters,... now is loaded from assets in the android port, failed to merge some stuff...
This commit is contained in:
parent
c6117bf501
commit
df13e8d1bc
3 changed files with 160 additions and 28 deletions
|
|
@ -39,6 +39,9 @@
|
|||
|
||||
#include "dirwalk.h"
|
||||
#include "progressbar.h"
|
||||
#ifdef __ANDROID__
|
||||
#include "android_assets.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
The following section renames global variables defined in SDL_Pango.h to avoid errors during linking.
|
||||
|
|
@ -278,20 +281,69 @@ void tp_ftw(SDL_Surface * screen, SDL_Texture * texture, SDL_Renderer * renderer
|
|||
tp_ftw_str *dir_names = NULL;
|
||||
int d_namlen;
|
||||
int add_rsrc;
|
||||
unsigned dlen;
|
||||
|
||||
dir[dirlen++] = '/';
|
||||
dir[dirlen] = '\0';
|
||||
//printf("processing directory %s %d\n", dir, dirlen);
|
||||
|
||||
dlen = dirlen;
|
||||
|
||||
/* Open the directory: */
|
||||
d = opendir(dir);
|
||||
#ifdef __ANDROID__
|
||||
char *di;
|
||||
AAssetDir *adir;
|
||||
|
||||
if (!d) /* Fallback into assets */
|
||||
{
|
||||
/* Remove the trailing '/' */
|
||||
dlen = strlen(dir) - 1;
|
||||
di = strndup(dir, dlen);
|
||||
adir = open_asset_dir(di);
|
||||
if (!adir)
|
||||
return;
|
||||
}
|
||||
#else
|
||||
if (!d)
|
||||
return;
|
||||
#endif
|
||||
|
||||
for (;;)
|
||||
{
|
||||
struct dirent *f = readdir(d);
|
||||
struct dirent *f;
|
||||
|
||||
if (d)
|
||||
f = readdir(d);
|
||||
int filetype = TP_FTW_UNKNOWN;
|
||||
|
||||
#ifdef __ANDROID__
|
||||
char *afilename;
|
||||
|
||||
if (!d)
|
||||
{
|
||||
afilename = AAssetDir_getNextFileName(adir);
|
||||
if (afilename)
|
||||
{
|
||||
f = malloc(sizeof(struct dirent));
|
||||
strncpy(f->d_name, afilename, sizeof(f->d_name));
|
||||
f->d_type = DT_REG;
|
||||
|
||||
/* There is not _DIRENT_HAVE_D_NAMLEN currently on Android 4.3, but who knows in the future... */
|
||||
#if defined(_DIRENT_HAVE_D_NAMLEN)
|
||||
f->d_namlen = strlen(f->d_name);
|
||||
#endif
|
||||
|
||||
/* AAssetDir_getNextFileName() only lists files, not (sub)dirs,
|
||||
and we don't put any device or special file inside assets,
|
||||
so it is a regular file */
|
||||
filetype = TP_FTW_NORMAL;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!f)
|
||||
break;
|
||||
if (f->d_name[0] == '.')
|
||||
|
|
@ -393,7 +445,12 @@ void tp_ftw(SDL_Surface * screen, SDL_Texture * texture, SDL_Renderer * renderer
|
|||
}
|
||||
free(file_names);
|
||||
#else
|
||||
fn(screen, texture, renderer, dir, dirlen, file_names, num_file_names, locale);
|
||||
#ifdef __ANDROID__
|
||||
if (dlen != dirlen) /* First case only happens in Android files coming from assets */
|
||||
fn(screen, texture, renderer, di, dlen, file_names, num_file_names, locale);
|
||||
else
|
||||
#endif
|
||||
fn(screen, texture, renderer, dir, dirlen, file_names, num_file_names, locale);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue