projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fixed element animation when collecting for BD engine
[rocksndiamonds.git]
/
src
/
libgame
/
image.c
diff --git
a/src/libgame/image.c
b/src/libgame/image.c
index 16b4574dab2022311cca9d25931efb07c16f56c5..4cc613e70062f8031c7703b7fbde5218b664f3dd 100644
(file)
--- a/
src/libgame/image.c
+++ b/
src/libgame/image.c
@@
-4,7
+4,7
@@
// (c) 1995-2014 by Artsoft Entertainment
// Holger Schemel
// info@artsoft.org
// (c) 1995-2014 by Artsoft Entertainment
// Holger Schemel
// info@artsoft.org
-// http://www.artsoft.org/
+// http
s
://www.artsoft.org/
// ----------------------------------------------------------------------------
// image.c
// ============================================================================
// ----------------------------------------------------------------------------
// image.c
// ============================================================================
@@
-21,17
+21,17
@@
struct ImageInfo
Bitmap *bitmaps[NUM_IMG_BITMAP_POINTERS];
Bitmap *bitmaps[NUM_IMG_BITMAP_POINTERS];
- int original_width; /
* original image file width */
- int original_height; /
* original image file height */
+ int original_width; /
/ original image file width
+ int original_height; /
/ original image file height
- boolean contains_small_images; /
* set after adding small images */
- boolean contains_textures; /
* set after adding GPU textures */
- boolean scaled_up; /
* set after scaling up */
+ boolean contains_small_images; /
/ set after adding small images
+ boolean contains_textures; /
/ set after adding GPU textures
+ boolean scaled_up; /
/ set after scaling up
- int conf_tile_size; /
* tile size as defined in config */
- int game_tile_size; /
* tile size as resized for game */
+ int conf_tile_size; /
/ tile size as defined in config
+ int game_tile_size; /
/ tile size as resized for game
- char *leveldir; /
* level set when image was loaded */
+ char *leveldir; /
/ level set when image was loaded
};
typedef struct ImageInfo ImageInfo;
};
typedef struct ImageInfo ImageInfo;
@@
-43,8
+43,7
@@
static void *Load_Image(char *filename)
if ((img_info->bitmaps[IMG_BITMAP_STANDARD] = LoadImage(filename)) == NULL)
{
if ((img_info->bitmaps[IMG_BITMAP_STANDARD] = LoadImage(filename)) == NULL)
{
- Error(ERR_WARN, "cannot load image file '%s': LoadImage() failed: %s",
- filename, GetError());
+ Warn("cannot load image file '%s': LoadImage() failed", filename);
free(img_info);
free(img_info);
@@
-86,7
+85,7
@@
static void FreeImage(void *ptr)
free(image);
}
free(image);
}
-int getImageListSize()
+int getImageListSize(
void
)
{
return (image_info->num_file_list_entries +
image_info->num_dynamic_file_list_entries);
{
return (image_info->num_file_list_entries +
image_info->num_dynamic_file_list_entries);
@@
-153,17
+152,17
@@
int getImageIDFromToken(char *token)
return -1;
}
return -1;
}
-char *getImageConfigFilename()
+char *getImageConfigFilename(
void
)
{
return getCustomArtworkConfigFilename(image_info->type);
}
{
return getCustomArtworkConfigFilename(image_info->type);
}
-int getImageListPropertyMappingSize()
+int getImageListPropertyMappingSize(
void
)
{
return image_info->num_property_mapping_entries;
}
{
return image_info->num_property_mapping_entries;
}
-struct PropertyMapping *getImageListPropertyMapping()
+struct PropertyMapping *getImageListPropertyMapping(
void
)
{
return image_info->property_mapping;
}
{
return image_info->property_mapping;
}
@@
-179,7
+178,7
@@
void InitImageList(struct ConfigInfo *config_list, int num_file_list_entries,
image_info = checked_calloc(sizeof(struct ArtworkListInfo));
image_info->type = ARTWORK_TYPE_GRAPHICS;
image_info = checked_calloc(sizeof(struct ArtworkListInfo));
image_info->type = ARTWORK_TYPE_GRAPHICS;
- /
* ---------- initialize file list and suffix lists ---------- */
+ /
/ ---------- initialize file list and suffix lists ----------
image_info->num_file_list_entries = num_file_list_entries;
image_info->num_dynamic_file_list_entries = 0;
image_info->num_file_list_entries = num_file_list_entries;
image_info->num_dynamic_file_list_entries = 0;
@@
-195,7
+194,7
@@
void InitImageList(struct ConfigInfo *config_list, int num_file_list_entries,
image_info->suffix_list = config_suffix_list;
image_info->suffix_list = config_suffix_list;
- /
* ---------- initialize base prefix and suffixes lists ---------- */
+ /
/ ---------- initialize base prefix and suffixes lists ----------
image_info->num_base_prefixes = 0;
for (i = 0; base_prefixes[i] != NULL; i++)
image_info->num_base_prefixes = 0;
for (i = 0; base_prefixes[i] != NULL; i++)
@@
-227,7
+226,7
@@
void InitImageList(struct ConfigInfo *config_list, int num_file_list_entries,
image_info->property_mapping = NULL;
image_info->property_mapping = NULL;
- /
* ---------- initialize artwork reference and content lists ---------- */
+ /
/ ---------- initialize artwork reference and content lists ----------
image_info->sizeof_artwork_list_entry = sizeof(ImageInfo *);
image_info->sizeof_artwork_list_entry = sizeof(ImageInfo *);
@@
-237,13
+236,13
@@
void InitImageList(struct ConfigInfo *config_list, int num_file_list_entries,
image_info->content_list = NULL;
image_info->content_list = NULL;
- /
* ---------- initialize artwork loading/freeing functions ---------- */
+ /
/ ---------- initialize artwork loading/freeing functions ----------
image_info->load_artwork = Load_Image;
image_info->free_artwork = FreeImage;
}
image_info->load_artwork = Load_Image;
image_info->free_artwork = FreeImage;
}
-void ReloadCustomImages()
+void ReloadCustomImages(
void
)
{
print_timestamp_init("ReloadCustomImages");
{
print_timestamp_init("ReloadCustomImages");
@@
-351,11
+350,11
@@
void CreateImageWithSmallImages(int pos, int zoom_factor, int tile_size)
setString(&img_info->leveldir, leveldir_current->identifier);
}
setString(&img_info->leveldir, leveldir_current->identifier);
}
-
static void CreateImageTexturesExt(int pos, boolean force
)
+
void CreateImageTextures(int pos
)
{
ImageInfo *img_info = getImageInfoEntryFromImageID(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);
return;
CreateBitmapTextures(img_info->bitmaps);
@@
-363,14
+362,25
@@
static void CreateImageTexturesExt(int pos, boolean force)
img_info->contains_textures = TRUE;
}
img_info->contains_textures = TRUE;
}
-
void Creat
eImageTextures(int pos)
+
static void Fre
eImageTextures(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(void
)
{
{
- 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)
}
void ScaleImage(int pos, int zoom_factor)
@@
-381,12
+391,14
@@
void ScaleImage(int pos, int zoom_factor)
return;
if (zoom_factor != 1)
return;
if (zoom_factor != 1)
+ {
ScaleBitmap(img_info->bitmaps, zoom_factor);
ScaleBitmap(img_info->bitmaps, zoom_factor);
- img_info->scaled_up = TRUE;
+ img_info->scaled_up = TRUE;
+ }
}
}
-void FreeAllImages()
+void FreeAllImages(
void
)
{
FreeCustomArtworkLists(image_info);
}
{
FreeCustomArtworkLists(image_info);
}