rnd-20131217-2-src
authorHolger Schemel <info@artsoft.org>
Tue, 17 Dec 2013 22:59:09 +0000 (23:59 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 09:00:21 +0000 (11:00 +0200)
* continued porting Rocks'n'Diamonds to Android (levels now playable)

ChangeLog
src/conftime.h
src/events.c
src/init.c
src/libgame/sdl.c
src/libgame/setup.c

index 24523b82fa6be638842bc8d6428d3537dad9a9b6..e3b6490bbfb635631bdb549fee9166fc6552c12c 100644 (file)
--- 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)
index 21ff7bdc1bdee223140f65b33157371a9802ab93..ee032df2a4f9ad7dac5af1859bb6aa62640bff87 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "2013-12-16 23:56"
+#define COMPILE_DATE_STRING "2013-12-17 18:30"
index d017a6343f9dc205540bd37ec277bbfb28a12542..0be6815b798acfd855e5644d1e745e3c721efcc9 100644 (file)
@@ -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
   }
index aa30167af3c2eb52e07aa3426de1ff5fc9d34703..e3bdd9c8f33fe0ca3f351f13cc0e9a294ecc5ada 100644 (file)
@@ -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)
index 52766b17d600c54f88dad072c26e258b0ca91022..f02264d9d27ef0fe5a9c997230bf9aecc3bb1379 100644 (file)
@@ -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
index 2f573e764af6adcb351b9616585101fc76411083..5dbbdada82fdd8309178c03eefd7bd04deeaad96 100644 (file)
@@ -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;
 }