rnd-20020402-1-src
[rocksndiamonds.git] / src / libgame / system.c
index 423570ddf4536407ecee19db0cf22e5045236797..7962345528d0213a492de88aea4e8cb5d160b01e 100644 (file)
@@ -40,8 +40,8 @@ struct ArtworkInfo    artwork;
 struct JoystickInfo    joystick;
 struct SetupInfo       setup;
 
-struct LevelDirInfo    *leveldir_first = NULL;
-struct LevelDirInfo    *leveldir_current = NULL;
+LevelDirTree          *leveldir_first = NULL;
+LevelDirTree          *leveldir_current = NULL;
 int                    level_nr;
 
 Display                       *display = NULL;
@@ -157,6 +157,8 @@ void InitGfxFieldInfo(int sx, int sy, int sxsize, int sysize,
   gfx.real_sy = real_sy;
   gfx.full_sxsize = full_sxsize;
   gfx.full_sysize = full_sysize;
+
+  SetDrawDeactivationMask(REDRAW_NONE);                /* do not deactivate drawing */
 }
 
 void InitGfxDoor1Info(int dx, int dy, int dxsize, int dysize)
@@ -182,6 +184,11 @@ void InitGfxScrollbufferInfo(int scrollbuffer_width, int scrollbuffer_height)
   gfx.scrollbuffer_height = scrollbuffer_height;
 }
 
+void SetDrawDeactivationMask(int draw_deactivation_mask)
+{
+  gfx.draw_deactivation_mask = draw_deactivation_mask;
+}
+
 
 /* ========================================================================= */
 /* video functions                                                           */
@@ -299,6 +306,9 @@ inline void FreeBitmap(Bitmap *bitmap)
     XFreeGC(display, bitmap->stored_clip_gc);
 #endif
 
+  if (bitmap->source_filename)
+    free(bitmap->source_filename);
+
   free(bitmap);
 }
 
@@ -315,11 +325,26 @@ inline void CloseWindow(DrawWindow *window)
 #endif
 }
 
+inline boolean DrawingDeactivated(int x, int y, int width, int height)
+{
+  if (gfx.draw_deactivation_mask != REDRAW_NONE)
+  {
+    if ((gfx.draw_deactivation_mask & REDRAW_FIELD) &&
+       x < gfx.sx + gfx.sxsize)
+      return TRUE;
+  }
+
+  return FALSE;
+}
+
 inline void BlitBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap,
                       int src_x, int src_y,
                       int width, int height,
                       int dst_x, int dst_y)
 {
+  if (DrawingDeactivated(dst_x, dst_y, width, height))
+    return;
+
 #ifdef TARGET_SDL
   SDLCopyArea(src_bitmap, dst_bitmap,
              src_x, src_y, width, height, dst_x, dst_y, SDLCOPYAREA_OPAQUE);
@@ -331,6 +356,9 @@ inline void BlitBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap,
 
 inline void ClearRectangle(Bitmap *bitmap, int x, int y, int width, int height)
 {
+  if (DrawingDeactivated(x, y, width, height))
+    return;
+
 #ifdef TARGET_SDL
   SDLFillRectangle(bitmap, x, y, width, height, 0x000000);
 #else
@@ -377,6 +405,9 @@ inline void BlitBitmapMasked(Bitmap *src_bitmap, Bitmap *dst_bitmap,
                             int width, int height,
                             int dst_x, int dst_y)
 {
+  if (DrawingDeactivated(dst_x, dst_y, width, height))
+    return;
+
 #ifdef TARGET_SDL
   SDLCopyArea(src_bitmap, dst_bitmap,
              src_x, src_y, width, height, dst_x, dst_y, SDLCOPYAREA_MASKED);
@@ -606,6 +637,19 @@ Bitmap *LoadImage(char *filename)
   return new_bitmap;
 }
 
+Bitmap *LoadCustomImage(char *basename)
+{
+  char *filename = getStringCopy(getCustomImageFilename(basename));
+  Bitmap *new_bitmap;
+
+  if ((new_bitmap = LoadImage(filename)) == NULL)
+    Error(ERR_EXIT, "LoadImage() failed: %s", GetError());
+
+  new_bitmap->source_filename = filename;
+
+  return new_bitmap;
+}
+
 
 /* ========================================================================= */
 /* audio functions                                                           */