added support for special media buttons on Amazon Fire TV remote control
[rocksndiamonds.git] / src / libgame / image.c
index 16b4574dab2022311cca9d25931efb07c16f56c5..699093b7b7ebb718e6a6d74144ba3c5b81caada8 100644 (file)
@@ -140,6 +140,13 @@ char *getTokenFromImageID(int graphic)
   return (file_list != NULL ? file_list->token : NULL);
 }
 
+char *getFilenameFromImageID(int graphic)
+{
+  struct FileInfo *file_list = getImageListEntryFromImageID(graphic);
+
+  return (file_list != NULL ? file_list->filename : NULL);
+}
+
 int getImageIDFromToken(char *token)
 {
   struct FileInfo *file_list = image_info->file_list;
@@ -351,11 +358,11 @@ void CreateImageWithSmallImages(int pos, int zoom_factor, int tile_size)
   setString(&img_info->leveldir, leveldir_current->identifier);
 }
 
-static void CreateImageTexturesExt(int pos, boolean force)
+void CreateImageTextures(int pos)
 {
   ImageInfo *img_info = getImageInfoEntryFromImageID(pos);
 
-  if (img_info == NULL || (img_info->contains_textures && !force))
+  if (img_info == NULL || img_info->contains_textures)
     return;
 
   CreateBitmapTextures(img_info->bitmaps);
@@ -363,14 +370,25 @@ static void CreateImageTexturesExt(int pos, boolean force)
   img_info->contains_textures = TRUE;
 }
 
-void CreateImageTextures(int pos)
+void FreeImageTextures(int pos)
 {
-  CreateImageTexturesExt(pos, FALSE);
+  ImageInfo *img_info = getImageInfoEntryFromImageID(pos);
+
+  if (img_info == NULL || !img_info->contains_textures)
+    return;
+
+  FreeBitmapTextures(img_info->bitmaps);
+
+  img_info->contains_textures = FALSE;
 }
 
-void ReCreateImageTextures(int pos)
+void FreeAllImageTextures()
 {
-  CreateImageTexturesExt(pos, TRUE);
+  int num_images = getImageListSize();
+  int i;
+
+  for (i = 0; i < num_images; i++)
+    FreeImageTextures(i);
 }
 
 void ScaleImage(int pos, int zoom_factor)