if (remap_toolbox_gadgets)
{
SetCurrentLevelColors_BD();
+ InitColorTemplateImagesIfNeeded();
ModifyEditorElementList();
RedrawDrawingElements();
{
int i;
- if (!hasColorTemplate_BD())
+ if (!hasColorTemplate())
{
int font_nr = FONT_TEXT_1;
int font_height = getFontHeight(font_nr);
LoadLevel_InitSettings(&level);
LoadLevel_InitNativeEngines(&level);
+
+ InitColorTemplateImagesIfNeeded();
}
void LoadLevel(int nr)
return bitmap;
}
+Bitmap *gd_get_colored_bitmap_from_template(Bitmap *template_bitmap)
+{
+ SDL_Surface *template_surface = get_tile_surface_c64(template_bitmap->surface, 1);
+ Bitmap *colored_bitmap = get_tile_bitmap_c64(native_bd_level.cave, template_surface);
+
+ return colored_bitmap;
+}
+
// returns true if the element has a certain property
static inline boolean has_property(const int element, const int property)
{
void gd_prepare_tile_bitmap(GdCave *cave, Bitmap *bitmap, int scale_down_factor);
void gd_set_tile_bitmap_reference(Bitmap *bitmap);
Bitmap *gd_get_tile_bitmap(Bitmap *bitmap);
+Bitmap *gd_get_colored_bitmap_from_template(Bitmap *template_bitmap);
int gd_drawcave(Bitmap *dest, GdGame *gameplay, boolean);
boolean gd_scroll(GdGame *gameplay, boolean exact_scroll, boolean immediate);
void PreparePreviewTileBitmap_BD(Bitmap *, int);
void SetPreviewTileBitmapReference_BD(Bitmap *);
Bitmap *GetPreviewTileBitmap_BD(Bitmap *);
+Bitmap *GetColoredBitmapFromTemplate_BD(Bitmap *);
unsigned int InitEngineRandom_BD(int);
void InitGameEngine_BD(void);
return gd_get_tile_bitmap(bitmap);
}
+Bitmap *GetColoredBitmapFromTemplate_BD(Bitmap *bitmap)
+{
+ return gd_get_colored_bitmap_from_template(bitmap);
+}
+
unsigned int InitEngineRandom_BD(int seed)
{
if (seed == NEW_RANDOMIZE)
graphic_info[i].bitmap = graphic_info[i].bitmaps[IMG_BITMAP_STANDARD];
}
+boolean hasColorTemplate(void)
+{
+ int num_images = getImageListSize();
+ int i;
+
+ for (i = 0; i < num_images; i++)
+ if (graphic_info[i].color_template)
+ return TRUE;
+
+ return FALSE;
+}
+
+void InitColorTemplateImages(void)
+{
+ int num_images = getImageListSize();
+ int i;
+
+ // if graphic is marked as "color template", reset using colored bitmaps
+ for (i = 0; i < num_images; i++)
+ if (graphic_info[i].color_template)
+ ResetColorTemplateImage(i);
+
+ // if graphic is marked as "color template", re-color all scaled bitmaps
+ for (i = 0; i < num_images; i++)
+ if (graphic_info[i].color_template)
+ CreateImgesFromColorTemplate(i, GetColoredBitmapFromTemplate_BD);
+
+ InitImageTextures();
+}
+
+void InitColorTemplateImagesIfNeeded(void)
+{
+ if (hasColorTemplate())
+ InitColorTemplateImages();
+}
+
void InitImageTextures(void)
{
static int texture_graphics[] =
void InitGadgets(void);
void InitImageTextures(void);
+boolean hasColorTemplate(void);
+void InitColorTemplateImages(void);
+void InitColorTemplateImagesIfNeeded(void);
+
void InitNetworkServer(void);
void DisplayExitMessage(char *, va_list);
}
}
+void ResetColorTemplateImage(int pos)
+{
+ ImageInfo *img_info = getImageInfoEntryFromImageID(pos);
+
+ if (img_info->template == NULL)
+ {
+ // image color template not yet defined -- copy from original bitmap
+ Bitmap *orig_bitmap = img_info->bitmaps[IMG_BITMAP_PTR_ORIGINAL];
+
+ img_info->template = ZoomBitmap(orig_bitmap, orig_bitmap->width, orig_bitmap->height);
+ }
+
+ img_info->contains_color_images = FALSE;
+}
+
+void CreateImgesFromColorTemplate(int pos, Bitmap * (*color_bitmap_function)(Bitmap *))
+{
+ ImageInfo *img_info = getImageInfoEntryFromImageID(pos);
+ int i;
+
+ if (img_info->contains_color_images)
+ return;
+
+ Bitmap *colored_bitmap = color_bitmap_function(img_info->template);
+
+ if (colored_bitmap != NULL)
+ {
+ // (re-)create all bitmaps from color template bitmap
+ for (i = 0; i < NUM_IMG_BITMAPS; i++)
+ {
+ Bitmap *old_bitmap = img_info->bitmaps[i];
+
+ if (old_bitmap == NULL)
+ continue;
+
+ // create new surfaces (with previous size) (this does not create textures)
+ Bitmap *new_bitmap = ZoomBitmap(colored_bitmap, old_bitmap->width, old_bitmap->height);
+
+ // free old surfaces
+ SDL_FreeSurface(old_bitmap->surface);
+ SDL_FreeSurface(old_bitmap->surface_masked);
+
+ // copy newly created surfaces from new bitmap
+ old_bitmap->surface = new_bitmap->surface;
+ old_bitmap->surface_masked = new_bitmap->surface_masked;
+
+ // free empty new bitmap structure
+ checked_free(new_bitmap);
+ }
+ }
+
+ // (also set if coloring failed, to prevent repeating for all graphics using this image)
+ img_info->contains_color_images = TRUE;
+}
+
void FreeAllImages(void)
{
FreeCustomArtworkLists(image_info);
void FreeAllImageTextures(void);
void ScaleImage(int, int);
+void ResetColorTemplateImage(int);
+void CreateImgesFromColorTemplate(int, Bitmap * (*color_bitmap_function)(Bitmap *));
+
void FreeAllImages(void);
#endif // IMAGE_H