From e9670d34c8443135027d243dfbc1e69ca0916b11 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 9 Oct 2024 19:12:06 +0200 Subject: [PATCH] fixed handling cloned graphics with color template --- src/editor.c | 2 +- src/init.c | 19 ++++++++++++++----- src/init.h | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/editor.c b/src/editor.c index d5f38ad7..dad6bebc 100644 --- a/src/editor.c +++ b/src/editor.c @@ -11909,7 +11909,7 @@ static void DrawEngineConfigColors(void) { int i; - if (!hasColorTemplate()) + if (!anyImagehasColorTemplate()) { int font_nr = FONT_TEXT_1; int font_height = getFontHeight(font_nr); diff --git a/src/init.c b/src/init.c index d93486c6..cf131e54 100644 --- a/src/init.c +++ b/src/init.c @@ -344,13 +344,22 @@ static void InitBitmapPointers(void) graphic_info[i].bitmap = graphic_info[i].bitmaps[IMG_BITMAP_STANDARD]; } -boolean hasColorTemplate(void) +static boolean hasColorTemplate(int graphic) +{ + // if graphic was cloned, only re-color cloned graphic + if (graphic_info[graphic].clone_from != -1) + return FALSE; + + return graphic_info[graphic].color_template; +} + +boolean anyImagehasColorTemplate(void) { int num_images = getImageListSize(); int i; for (i = 0; i < num_images; i++) - if (graphic_info[i].color_template) + if (hasColorTemplate(i)) return TRUE; return FALSE; @@ -363,12 +372,12 @@ void InitColorTemplateImages(void) // if graphic is marked as "color template", reset using colored bitmaps for (i = 0; i < num_images; i++) - if (graphic_info[i].color_template) + if (hasColorTemplate(i)) 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) + if (hasColorTemplate(i)) CreateImgesFromColorTemplate(i, GetColoredBitmapFromTemplate_BD); InitImageTextures(); @@ -376,7 +385,7 @@ void InitColorTemplateImages(void) void InitColorTemplateImagesIfNeeded(void) { - if (hasColorTemplate()) + if (anyImagehasColorTemplate()) InitColorTemplateImages(); } diff --git a/src/init.h b/src/init.h index 65f21ddf..7fcbfcd6 100644 --- a/src/init.h +++ b/src/init.h @@ -40,7 +40,7 @@ void InitGfxBuffers(void); void InitGadgets(void); void InitImageTextures(void); -boolean hasColorTemplate(void); +boolean anyImagehasColorTemplate(void); void InitColorTemplateImages(void); void InitColorTemplateImagesIfNeeded(void); -- 2.34.1