From d6a1a6cb31174ac804f9ad54a919d65478da588f Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Tue, 17 Dec 2013 23:59:09 +0100 Subject: [PATCH] rnd-20131217-2-src * continued porting Rocks'n'Diamonds to Android (levels now playable) --- ChangeLog | 5 ++++- src/conftime.h | 2 +- src/events.c | 20 +++++++++++++++++--- src/init.c | 18 ++++++++++++++++++ src/libgame/sdl.c | 1 + src/libgame/setup.c | 5 +++++ 6 files changed, 46 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 24523b82..e3b6490b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2013-12-16 + * continued porting Rocks'n'Diamonds to Android (levels now playable) + 2013-12-12 * added SDL2 renderer/texture based graphics frame handling to allow for "desktop" style fullscreen mode and scaling of game screen/window @@ -12,7 +15,7 @@ surface are the same (this bug also existed in versions of SDL 1.2.x) 2013-12-07 - * started porting Rocks'n'Diamonds to Android + * started porting Rocks'n'Diamonds to Android (already shows main menu) 2013-12-03 * ported Rocks'n'Diamonds to SDL2 (first simple version that works) diff --git a/src/conftime.h b/src/conftime.h index 21ff7bdc..ee032df2 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2013-12-16 23:56" +#define COMPILE_DATE_STRING "2013-12-17 18:30" diff --git a/src/events.c b/src/events.c index d017a634..0be6815b 100644 --- a/src/events.c +++ b/src/events.c @@ -409,11 +409,13 @@ void HandleFingerEvent(FingerEvent *event) event->pressure); #endif +#if 0 int x = (int)(event->x * video.width); int y = (int)(event->y * video.height); int button = MB_LEFTBUTTON; Error(ERR_DEBUG, "=> screen x/y %d/%d", x, y); +#endif #if 0 if (++num_events >= max_events) @@ -421,6 +423,7 @@ void HandleFingerEvent(FingerEvent *event) #endif #if 1 +#if 0 if (event->type == EVENT_FINGERPRESS || event->type == EVENT_FINGERMOTION) button_status = button; @@ -429,17 +432,30 @@ void HandleFingerEvent(FingerEvent *event) int max_x = SX + SXSIZE; int max_y = SY + SYSIZE; +#endif +#if 1 + if (game_status == GAME_MODE_PLAYING) +#else if (game_status == GAME_MODE_PLAYING && x < max_x) +#endif { int key_status = (event->type == EVENT_FINGERRELEASE ? KEY_RELEASED : KEY_PRESSED); +#if 1 + Key key = (event->y < 1.0 / 3.0 ? setup.input[0].key.up : + event->y > 2.0 / 3.0 ? setup.input[0].key.down : + event->x < 1.0 / 3.0 ? setup.input[0].key.left : + event->x > 2.0 / 3.0 ? setup.input[0].key.right : + setup.input[0].key.drop); +#else Key key = (y < max_y / 3 ? setup.input[0].key.up : y > 2 * max_y / 3 ? setup.input[0].key.down : x < max_x / 3 ? setup.input[0].key.left : x > 2 * max_x / 3 ? setup.input[0].key.right : setup.input[0].key.drop); +#endif Error(ERR_DEBUG, "=> key == %d, key_status == %d", key, key_status); @@ -447,12 +463,10 @@ void HandleFingerEvent(FingerEvent *event) } else { -#if 1 +#if 0 Error(ERR_DEBUG, "::: button_status == %d, button == %d\n", button_status, button); -#endif -#if 1 HandleButton(x, y, button_status, button); #endif } diff --git a/src/init.c b/src/init.c index aa30167a..e3bdd9c8 100644 --- a/src/init.c +++ b/src/init.c @@ -6372,6 +6372,24 @@ void OpenAll() DrawMainMenu(); InitNetworkServer(); + +#if 0 + Error(ERR_DEBUG, "::: SDL_GetBasePath() == '%s'", + SDL_GetBasePath()); + Error(ERR_DEBUG, "::: SDL_GetPrefPath() == '%s'", + SDL_GetPrefPath("artsoft", "rocksndiamonds")); +#if defined(PLATFORM_ANDROID) + Error(ERR_DEBUG, "::: SDL_AndroidGetInternalStoragePath() == '%s'", + SDL_AndroidGetInternalStoragePath()); + Error(ERR_DEBUG, "::: SDL_AndroidGetExternalStoragePath() == '%s'", + SDL_AndroidGetExternalStoragePath()); + Error(ERR_DEBUG, "::: SDL_AndroidGetExternalStorageState() == '%s'", + (SDL_AndroidGetExternalStorageState() == + SDL_ANDROID_EXTERNAL_STORAGE_READ ? "read" : + SDL_AndroidGetExternalStorageState() == + SDL_ANDROID_EXTERNAL_STORAGE_WRITE ? "write" : "not available")); +#endif +#endif } void CloseAllAndExit(int exit_value) diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index 52766b17..f02264d9 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -271,6 +271,7 @@ void SDLInitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window, Error(ERR_EXIT, "setting video mode failed"); #if 1 + /* !!! SDL2 can only set the window icon if the window already exists !!! */ /* set window icon */ SDLSetWindowIcon(program.sdl_icon_filename); #endif diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 2f573e76..5dbbdada 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -1375,9 +1375,14 @@ char *getUserGameDataDir(void) { static char *user_game_data_dir = NULL; +#if defined(PLATFORM_ANDROID) + if (user_game_data_dir == NULL) + user_game_data_dir = SDL_AndroidGetInternalStoragePath(); +#else if (user_game_data_dir == NULL) user_game_data_dir = getPath2(getPersonalDataDir(), program.userdata_subdir); +#endif return user_game_data_dir; } -- 2.34.1