added code for overlay touch buttons (currently not used)
[rocksndiamonds.git] / src / init.c
index 8d410a560b7aabd74c4f1d57cde209251cc9cab5..409858ca45e0c4e670534c8ecaa01076e719009a 100644 (file)
@@ -275,6 +275,10 @@ static void InitBitmapPointers(void)
 
 void InitImageTextures(void)
 {
+  static int texture_graphics[] =
+  {
+    -1
+  };
   int i, j, k;
 
   FreeAllImageTextures();
@@ -300,6 +304,9 @@ void InitImageTextures(void)
       }
     }
   }
+
+  for (i = 0; texture_graphics[i] > -1; i++)
+    CreateImageTextures(texture_graphics[i]);
 }
 
 #if 1
@@ -481,8 +488,8 @@ static void InitFontGraphicInfo(void)
   }
 
   // reset non-redefined ".active" font graphics if normal font is redefined
-  /* (this different treatment is needed because normal and active fonts are
-     independently defined ("active" is not a property of font definitions!) */
+  // (this different treatment is needed because normal and active fonts are
+  // independently defined ("active" is not a property of font definitions!)
   for (i = 0; i < NUM_FONTS; i++)
   {
     int font_nr_base = i;
@@ -515,8 +522,8 @@ static void InitFontGraphicInfo(void)
        boolean active_redefined =
          getImageListEntryFromImageID(active_graphic)->redefined;
 
-       /* same as above, but check special graphic definitions, for example:
-          redefined "font.menu_1.MAIN" invalidates "font.menu_1.active.MAIN" */
+       // same as above, but check special graphic definitions, for example:
+       // redefined "font.menu_1.MAIN" invalidates "font.menu_1.active.MAIN"
        if (base_redefined && !active_redefined)
        {
          font_info[font_nr_active].special_graphic[j] =
@@ -955,8 +962,8 @@ static void InitElementGraphicInfo(void)
 
   UPDATE_BUSY_STATE();
 
-  /* adjust graphics with 2nd tile for movement according to direction
-     (do this before correcting '-1' values to minimize calculations) */
+  // adjust graphics with 2nd tile for movement according to direction
+  // (do this before correcting '-1' values to minimize calculations)
   for (i = 0; i < MAX_NUM_ELEMENTS; i++)
   {
     for (act = 0; act < NUM_ACTIONS; act++)
@@ -1297,12 +1304,15 @@ static void set_graphic_parameters_ext(int graphic, int *parameter,
   g->clone_from = -1;                  // do not use clone graphic
   g->init_delay_fixed = 0;
   g->init_delay_random = 0;
+  g->init_delay_action = -1;
   g->anim_delay_fixed = 0;
   g->anim_delay_random = 0;
+  g->anim_delay_action = -1;
   g->post_delay_fixed = 0;
   g->post_delay_random = 0;
-  g->init_event = ANIM_EVENT_DEFAULT;
-  g->anim_event = ANIM_EVENT_DEFAULT;
+  g->post_delay_action = -1;
+  g->init_event = ANIM_EVENT_UNDEFINED;
+  g->anim_event = ANIM_EVENT_UNDEFINED;
   g->init_event_action = -1;
   g->anim_event_action = -1;
   g->draw_masked = FALSE;
@@ -1311,6 +1321,7 @@ static void set_graphic_parameters_ext(int graphic, int *parameter,
   g->fade_delay = -1;
   g->post_delay = -1;
   g->auto_delay = -1;
+  g->auto_delay_unit = AUTO_DELAY_UNIT_DEFAULT;
   g->align = ALIGN_CENTER;             // default for title screens
   g->valign = VALIGN_MIDDLE;           // default for title screens
   g->sort_priority = 0;                        // default for title screens
@@ -1472,7 +1483,7 @@ static void set_graphic_parameters_ext(int graphic, int *parameter,
   else
     g->anim_frames = 1;
 
-  if (g->anim_frames == 0)             // frames must be at least 1
+  if (g->anim_frames < 1)              // frames must be at least 1
     g->anim_frames = 1;
 
   g->anim_frames_per_line =
@@ -1480,7 +1491,7 @@ static void set_graphic_parameters_ext(int graphic, int *parameter,
      parameter[GFX_ARG_FRAMES_PER_LINE] : anim_frames_per_line);
 
   g->anim_delay = parameter[GFX_ARG_DELAY];
-  if (g->anim_delay == 0)              // delay must be at least 1
+  if (g->anim_delay < 1)               // delay must be at least 1
     g->anim_delay = 1;
 
   g->anim_mode = parameter[GFX_ARG_ANIM_MODE];
@@ -1531,6 +1542,12 @@ static void set_graphic_parameters_ext(int graphic, int *parameter,
     g->init_event_action = parameter[GFX_ARG_INIT_EVENT_ACTION];
   if (parameter[GFX_ARG_ANIM_EVENT_ACTION] != ARG_UNDEFINED_VALUE)
     g->anim_event_action = parameter[GFX_ARG_ANIM_EVENT_ACTION];
+  if (parameter[GFX_ARG_INIT_DELAY_ACTION] != ARG_UNDEFINED_VALUE)
+    g->init_delay_action = parameter[GFX_ARG_INIT_DELAY_ACTION];
+  if (parameter[GFX_ARG_ANIM_DELAY_ACTION] != ARG_UNDEFINED_VALUE)
+    g->anim_delay_action = parameter[GFX_ARG_ANIM_DELAY_ACTION];
+  if (parameter[GFX_ARG_POST_DELAY_ACTION] != ARG_UNDEFINED_VALUE)
+    g->post_delay_action = parameter[GFX_ARG_POST_DELAY_ACTION];
 
   // used for toon animations and global animations
   g->step_offset  = parameter[GFX_ARG_STEP_OFFSET];
@@ -1542,6 +1559,9 @@ static void set_graphic_parameters_ext(int graphic, int *parameter,
   g->x            = parameter[GFX_ARG_X];      // (may be uninitialized,
   g->y            = parameter[GFX_ARG_Y];      // unlike src_x and src_y)
 
+  if (g->step_delay < 1)                       // delay must be at least 1
+    g->step_delay = 1;
+
   // this is only used for drawing font characters
   g->draw_xoffset = parameter[GFX_ARG_DRAW_XOFFSET];
   g->draw_yoffset = parameter[GFX_ARG_DRAW_YOFFSET];
@@ -1572,6 +1592,8 @@ static void set_graphic_parameters_ext(int graphic, int *parameter,
     g->post_delay = parameter[GFX_ARG_POST_DELAY];
   if (parameter[GFX_ARG_AUTO_DELAY] != ARG_UNDEFINED_VALUE)
     g->auto_delay = parameter[GFX_ARG_AUTO_DELAY];
+  if (parameter[GFX_ARG_AUTO_DELAY_UNIT] != ARG_UNDEFINED_VALUE)
+    g->auto_delay_unit = parameter[GFX_ARG_AUTO_DELAY_UNIT];
   if (parameter[GFX_ARG_ALIGN] != ARG_UNDEFINED_VALUE)
     g->align = parameter[GFX_ARG_ALIGN];
   if (parameter[GFX_ARG_VALIGN] != ARG_UNDEFINED_VALUE)
@@ -1723,6 +1745,8 @@ static void InitGraphicInfo(void)
     -1
   };
 
+  FreeGlobalAnimEventInfo();
+
   checked_free(graphic_info);
 
   graphic_info = checked_calloc(num_images * sizeof(struct GraphicInfo));
@@ -1970,8 +1994,8 @@ static void InitElementSoundInfo(void)
     }
   }
 
-  /* copy sound settings to some elements that are only stored in level file
-     in native R'n'D levels, but are used by game engine in native EM levels */
+  // copy sound settings to some elements that are only stored in level file
+  // in native R'n'D levels, but are used by game engine in native EM levels
   for (i = 0; copy_properties[i][0] != -1; i++)
     for (j = 1; j <= 4; j++)
       for (act = 0; act < NUM_ACTIONS; act++)
@@ -2151,8 +2175,8 @@ static void InitGameModeMusicInfo(void)
   }
 
   // now set all '-1' values to menu specific default values
-  /* (undefined values of "levelset.music[]" might stay at "-1" to
-     allow dynamic selection of music files from music directory!) */
+  // (undefined values of "levelset.music[]" might stay at "-1" to
+  // allow dynamic selection of music files from music directory!)
   for (i = 0; i < MAX_LEVELS; i++)
     if (levelset.music[i] == -1)
       levelset.music[i] = default_levelset_music;
@@ -3687,8 +3711,8 @@ void InitElementPropertiesStatic(void)
     EL_WALL_PEARL,
     EL_WALL_CRYSTAL,
 
-    /* the following elements are a direct copy of "indestructible" elements,
-       except "EL_ACID", which is "indestructible", but not "solid"! */
+    // the following elements are a direct copy of "indestructible" elements,
+    // except "EL_ACID", which is "indestructible", but not "solid"!
 #if 0
     EL_ACID,
 #endif
@@ -6061,6 +6085,8 @@ void OpenAll(void)
 
   InitNetworkSettings();
 
+  InitRuntimeInfo();
+
   if (network.serveronly)
   {
 #if defined(PLATFORM_UNIX)
@@ -6095,6 +6121,8 @@ void OpenAll(void)
   InitVideoBuffer(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, setup.fullscreen);
   InitVideoOverlay();
 
+  InitEventFilter(FilterMouseMotionEvents);
+
   print_timestamp_time("[init video stuff]");
 
   InitElementPropertiesStatic();
@@ -6194,16 +6222,13 @@ void CloseAllAndExit(int exit_value)
 
   FreeAllImages();
 
-#if defined(TARGET_SDL)
-#if defined(TARGET_SDL2)
   // !!! TODO !!!
   // set a flag to tell the network server thread to quit and wait for it
   // using SDL_WaitThread()
-#else
-  if (network_server)  // terminate network server
-    SDL_KillThread(server_thread);
-#endif
-#endif
+  //
+  // Code used with SDL 1.2:
+  // if (network_server)       // terminate network server
+  //   SDL_KillThread(server_thread);
 
   CloseVideoDisplay();
   ClosePlatformDependentStuff();