diff --git a/android/AndroidManifest.xml.in b/android/AndroidManifest.xml.in index d793a20..5569ab3 100644 --- a/android/AndroidManifest.xml.in +++ b/android/AndroidManifest.xml.in @@ -10,7 +10,7 @@ android:label="@string/app_name" android:launchMode="singleTask" android:screenOrientation="unspecified" - android:configChanges="screenLayout|uiMode|orientation"> + android:configChanges="screenLayout|uiMode|orientation|screenSize"> diff --git a/cmake/android.toolchain b/cmake/android.toolchain index 9d96dc2..893b2b6 100644 --- a/cmake/android.toolchain +++ b/cmake/android.toolchain @@ -1,14 +1,13 @@ - SET(CMAKE_SYSTEM_NAME Linux) SET(CMAKE_SYSTEM_VERSION 1) #set path for android toolchain -- look -set(ANDROID_ALLEGRO_ROOT "$ENV{ANDROID_ALLEGRO_ROOT}" CACHE PATH "Path to Allegro 5 source directory after being compiled for Android" ) +set(ANDROID_ALLEGRO_ROOT "$ENV{ANDROID_ALLEGRO_ROOT}" CACHE PATH "Path to Allegro 5 (>=5.2.2) build directory for Android" ) message( STATUS "Selected Allegro dir: ${ANDROID_ALLEGRO_ROOT}" ) -if(NOT EXISTS ${ANDROID_ALLEGRO_ROOT}) - message( FATAL_ERROR "Invalid ANDROID_ALLEGRO_ROOT! Point it to directory with Allegro 5 source after compiling it for Android.") +if(NOT EXISTS "${ANDROID_ALLEGRO_ROOT}") + message( FATAL_ERROR "Invalid ANDROID_ALLEGRO_ROOT! Point it to the build directory of Allegro 5 (>=5.2.2) for Android.") endif() set(ANDROID_NDK_TOOLCHAIN_ROOT "$ENV{ANDROID_NDK_TOOLCHAIN_ROOT}" CACHE PATH "Path to the Android NDK Standalone Toolchain" ) diff --git a/cmake/libsuperderpy.cmake b/cmake/libsuperderpy.cmake index c7c59c1..fcd86bc 100644 --- a/cmake/libsuperderpy.cmake +++ b/cmake/libsuperderpy.cmake @@ -155,7 +155,7 @@ if(ANDROID) file(RENAME "${CMAKE_BINARY_DIR}/android/src/net/dosowisko/libsuperderpy" "${CMAKE_BINARY_DIR}/android/src/net/dosowisko/${LIBSUPERDERPY_GAMENAME}") file(COPY ${ALLEGRO5_LIBS} DESTINATION ${LIBRARY_OUTPUT_PATH}) - file(COPY "${ANDROID_ALLEGRO_ROOT}/android/libs/${ARM_TARGETS}/Allegro5.jar" DESTINATION ${LIBRARY_OUTPUT_PATH}) + file(COPY "${ANDROID_ALLEGRO_ROOT}/lib/Allegro5.jar" DESTINATION ${LIBRARY_OUTPUT_PATH}) file(COPY "${CMAKE_SOURCE_DIR}/data/" DESTINATION "${CMAKE_BINARY_DIR}/android/assets/") diff --git a/src/libsuperderpy.c b/src/libsuperderpy.c index 1f369c0..6eca284 100644 --- a/src/libsuperderpy.c +++ b/src/libsuperderpy.c @@ -130,7 +130,7 @@ SYMBOL_EXPORT struct Game* libsuperderpy_init(int argc, char** argv, const char* al_set_mouse_emulation_mode(ALLEGRO_MOUSE_EMULATION_TRANSPARENT); #endif - al_set_new_display_flags(ALLEGRO_PROGRAMMABLE_PIPELINE | (game->config.fullscreen ? ALLEGRO_FULLSCREEN_WINDOW : ALLEGRO_WINDOWED) | ALLEGRO_RESIZABLE | ALLEGRO_OPENGL ); + al_set_new_display_flags(ALLEGRO_PROGRAMMABLE_PIPELINE | (game->config.fullscreen ? ALLEGRO_FULLSCREEN_WINDOW : ALLEGRO_WINDOWED) | ALLEGRO_RESIZABLE | ALLEGRO_OPENGL ); // TODO: make ALLEGRO_PROGRAMMABLE_PIPELINE game-optional al_set_new_display_option(ALLEGRO_VSYNC, 2-atoi(GetConfigOptionDefault(game, "SuperDerpy", "vsync", "1")), ALLEGRO_SUGGEST); al_set_new_display_option(ALLEGRO_OPENGL, atoi(GetConfigOptionDefault(game, "SuperDerpy", "opengl", "1")), ALLEGRO_SUGGEST); #ifdef ALLEGRO_WINDOWS @@ -399,18 +399,21 @@ SYMBOL_EXPORT int libsuperderpy_run(struct Game *game) { SetupViewport(game, game->viewport_config); } else if(ev.type == ALLEGRO_EVENT_DISPLAY_HALT_DRAWING) { + PrintConsole(game, "halt drawing"); game->_priv.draw = false; al_stop_timer(game->_priv.timer); al_detach_voice(game->audio.v); + PauseAllGamestates(game); // TODO: store not paused gamestates al_acknowledge_drawing_halt(game->display); - continue; } else if(ev.type == ALLEGRO_EVENT_DISPLAY_RESUME_DRAWING) { - al_attach_mixer_to_voice(game->audio.mixer, game->audio.v); - game->_priv.draw = true; al_acknowledge_drawing_resume(game->display); - al_resume_timer(game->_priv.timer); + PrintConsole(game, "resume drawing"); + game->_priv.draw = true; SetupViewport(game, game->viewport_config); + ResumeAllGamestates(game); // FIXME: resumes even those that were paused earlier! + al_attach_mixer_to_voice(game->audio.mixer, game->audio.v); + al_resume_timer(game->_priv.timer); } else if(ev.type == ALLEGRO_EVENT_DISPLAY_RESIZE) { al_acknowledge_resize(game->display); @@ -456,9 +459,8 @@ SYMBOL_EXPORT int libsuperderpy_run(struct Game *game) { al_save_bitmap(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP), al_get_backbuffer(game->display)); PrintConsole(game, "Screenshot stored in %s", al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP)); al_destroy_path(path); - } else { - EventGamestates(game, &ev); } + EventGamestates(game, &ev); } ClearGarbage(game); } diff --git a/src/utils.c b/src/utils.c index 8edb5b7..a5cb7fc 100644 --- a/src/utils.c +++ b/src/utils.c @@ -317,12 +317,15 @@ SYMBOL_EXPORT char* GetDataFilePath(struct Game *game, char* filename) { return AddGarbage(game, result); } +ALLEGRO_DEBUG_CHANNEL("libsuperderpy") + SYMBOL_EXPORT void PrintConsole(struct Game *game, char* format, ...) { va_list vl; va_start(vl, format); char text[1024] = {}; vsnprintf(text, 1024, format, vl); va_end(vl); + ALLEGRO_DEBUG(text); if (game->config.debug) { printf("%s\n", text); fflush(stdout); } if (!game->_priv.draw) return; if (!game->_priv.console) return;