mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-29 17:38:16 +03:00
Android port
This commit is contained in:
committed by
Misa Elizabeth Kai
parent
6e18cddc69
commit
4229372c2e
@@ -183,6 +183,14 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath, char* langD
|
||||
|
||||
PHYSFS_setAllocator(&allocator);
|
||||
|
||||
// Yes, this is actually how you're supposed to use PhysFS on Android.
|
||||
#ifdef __ANDROID__
|
||||
PHYSFS_AndroidInit androidInit;
|
||||
androidInit.jnienv = SDL_AndroidGetJNIEnv();
|
||||
androidInit.context = SDL_AndroidGetActivity();
|
||||
argvZero = (char*) &androidInit;
|
||||
#endif
|
||||
|
||||
if (!PHYSFS_init(argvZero))
|
||||
{
|
||||
vlog_error(
|
||||
@@ -264,6 +272,16 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath, char* langD
|
||||
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))
|
||||
{
|
||||
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))
|
||||
#else
|
||||
if (assetsPath)
|
||||
{
|
||||
SDL_strlcpy(output, assetsPath, sizeof(output));
|
||||
@@ -276,6 +294,7 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath, char* langD
|
||||
);
|
||||
}
|
||||
if (!PHYSFS_mount(output, NULL, 1))
|
||||
#endif
|
||||
{
|
||||
vlog_error("Error: data.zip missing!");
|
||||
vlog_error("You do not have data.zip!");
|
||||
@@ -1234,6 +1253,18 @@ static int PLATFORM_getOSDirectory(char* output, const size_t output_size)
|
||||
SDL_strlcat(output, "\\VVVVVV\\", MAX_PATH);
|
||||
mkdir(output, 0777);
|
||||
return 1;
|
||||
#elif defined(__ANDROID__)
|
||||
const char* externalStoragePath = SDL_AndroidGetExternalStoragePath();
|
||||
if (externalStoragePath == NULL)
|
||||
{
|
||||
vlog_error(
|
||||
"Could not get OS directory: %s",
|
||||
SDL_GetError()
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
SDL_snprintf(output, output_size, "%s/", externalStoragePath);
|
||||
return 1;
|
||||
#else
|
||||
const char* prefDir = PHYSFS_getPrefDir("distractionware", "VVVVVV");
|
||||
if (prefDir == NULL)
|
||||
|
||||
@@ -376,6 +376,12 @@ void Screen::recacheTextures(void)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __ANDROID__
|
||||
bool Screen::isForcedFullscreen(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
bool Screen::isForcedFullscreen(void)
|
||||
{
|
||||
/* This is just a check to see if we're on a desktop or tenfoot setup.
|
||||
@@ -384,3 +390,4 @@ bool Screen::isForcedFullscreen(void)
|
||||
*/
|
||||
return SDL_GetHintBoolean("SteamTenfoot", SDL_FALSE);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
#ifdef _WIN32
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
#elif defined(__ANDROID__)
|
||||
// forward to SDL logging on Android, since stdout/stderr are /dev/null
|
||||
# include <SDL.h>
|
||||
#elif defined(__unix__) || defined(__APPLE__)
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
@@ -29,6 +32,9 @@ static void check_color_support(void);
|
||||
|
||||
void vlog_init(void)
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_VERBOSE);
|
||||
#endif
|
||||
check_color_support();
|
||||
}
|
||||
|
||||
@@ -71,6 +77,11 @@ SDL_PRINTF_VARARG_FUNC(1) void vlog_debug(const char* text, ...)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef __ANDROID__
|
||||
va_start(list, text);
|
||||
SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, text, list);
|
||||
va_end(list);
|
||||
#else
|
||||
printf(Color_BOLD_GRAY);
|
||||
printf("[DEBUG]");
|
||||
printf(Color_RESET);
|
||||
@@ -81,6 +92,7 @@ SDL_PRINTF_VARARG_FUNC(1) void vlog_debug(const char* text, ...)
|
||||
va_end(list);
|
||||
|
||||
putchar('\n');
|
||||
#endif
|
||||
}
|
||||
|
||||
SDL_PRINTF_VARARG_FUNC(1) void vlog_info(const char* text, ...)
|
||||
@@ -92,6 +104,11 @@ SDL_PRINTF_VARARG_FUNC(1) void vlog_info(const char* text, ...)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef __ANDROID__
|
||||
va_start(list, text);
|
||||
SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, text, list);
|
||||
va_end(list);
|
||||
#else
|
||||
printf(Color_BOLD);
|
||||
printf("[INFO]");
|
||||
printf(Color_RESET);
|
||||
@@ -102,6 +119,7 @@ SDL_PRINTF_VARARG_FUNC(1) void vlog_info(const char* text, ...)
|
||||
va_end(list);
|
||||
|
||||
putchar('\n');
|
||||
#endif
|
||||
}
|
||||
|
||||
SDL_PRINTF_VARARG_FUNC(1) void vlog_warn(const char* text, ...)
|
||||
@@ -113,6 +131,11 @@ SDL_PRINTF_VARARG_FUNC(1) void vlog_warn(const char* text, ...)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef __ANDROID__
|
||||
va_start(list, text);
|
||||
SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, text, list);
|
||||
va_end(list);
|
||||
#else
|
||||
fprintf(stderr, Color_BOLD_YELLOW);
|
||||
fprintf(stderr, "[WARN]");
|
||||
fprintf(stderr, Color_RESET);
|
||||
@@ -123,6 +146,7 @@ SDL_PRINTF_VARARG_FUNC(1) void vlog_warn(const char* text, ...)
|
||||
va_end(list);
|
||||
|
||||
fputc('\n', stderr);
|
||||
#endif
|
||||
}
|
||||
|
||||
SDL_PRINTF_VARARG_FUNC(1) void vlog_error(const char* text, ...)
|
||||
@@ -134,6 +158,11 @@ SDL_PRINTF_VARARG_FUNC(1) void vlog_error(const char* text, ...)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef __ANDROID__
|
||||
va_start(list, text);
|
||||
SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_ERROR, text, list);
|
||||
va_end(list);
|
||||
#else
|
||||
fprintf(stderr, Color_BOLD_RED);
|
||||
fprintf(stderr, "[ERROR]");
|
||||
fprintf(stderr, Color_RESET);
|
||||
@@ -144,6 +173,7 @@ SDL_PRINTF_VARARG_FUNC(1) void vlog_error(const char* text, ...)
|
||||
va_end(list);
|
||||
|
||||
fputc('\n', stderr);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -225,7 +255,7 @@ static void check_color_support(void)
|
||||
}
|
||||
|
||||
color_supported = 1;
|
||||
#elif defined(__unix__) || defined(__APPLE__)
|
||||
#elif (defined(__unix__) || defined(__APPLE__)) && !defined(__ANDROID__)
|
||||
if (isatty(STDOUT_FILENO) && isatty(STDERR_FILENO))
|
||||
{
|
||||
color_supported = 1;
|
||||
|
||||
Reference in New Issue
Block a user