From: Holger Schemel Date: Tue, 31 Jan 2023 23:42:10 +0000 (+0100) Subject: added support for x/y/width/height parameters for border/background images X-Git-Tag: 4.3.5.0~22 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=92534b4d22c4042737e2cbc50b487980759cf6a8;p=rocksndiamonds.git added support for x/y/width/height parameters for border/background images --- diff --git a/src/init.c b/src/init.c index f07be1d3..bdcff368 100644 --- a/src/init.c +++ b/src/init.c @@ -110,14 +110,14 @@ static int copy_properties[][5] = static int get_graphic_parameter_value(char *, char *, int); -static Bitmap *getLoadingBackgroundBitmap(int graphic) +static int getLoadingBackgroundImage(int graphic) { - return getBitmapFromGraphicOrDefault(graphic, INITIAL_IMG_BACKGROUND); + return getImageFromGraphicOrDefault(graphic, INITIAL_IMG_BACKGROUND); } static void SetLoadingWindowBackgroundImage(int graphic) { - SetWindowBackgroundBitmap(getLoadingBackgroundBitmap(graphic)); + SetBackgroundImage(getLoadingBackgroundImage(graphic), REDRAW_ALL); } static void SetLoadingBackgroundImage(void) @@ -5655,7 +5655,6 @@ void InitGfxBuffers(void) } ReCreateBitmap(&bitmap_db_field, FXSIZE, FYSIZE); - ReCreateBitmap(&bitmap_db_panel, DXSIZE, DYSIZE); ReCreateBitmap(&bitmap_db_door_1, 3 * DXSIZE, DYSIZE); ReCreateBitmap(&bitmap_db_door_2, 3 * VXSIZE, VYSIZE); diff --git a/src/libgame/system.c b/src/libgame/system.c index b1d667c2..1b2a41f4 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -449,7 +449,8 @@ void SetDrawBackgroundMask(int draw_background_mask) gfx.draw_background_mask = draw_background_mask; } -static void SetBackgroundBitmap(Bitmap *background_bitmap_tile, int mask) +void SetBackgroundBitmap(Bitmap *background_bitmap_tile, int mask, + int x, int y, int width, int height) { if (background_bitmap_tile != NULL) gfx.background_bitmap_mask |= mask; @@ -460,40 +461,19 @@ static void SetBackgroundBitmap(Bitmap *background_bitmap_tile, int mask) return; if (mask == REDRAW_ALL) - BlitBitmapTiled(background_bitmap_tile, gfx.background_bitmap, 0, 0, 0, 0, + BlitBitmapTiled(background_bitmap_tile, gfx.background_bitmap, + x, y, width, height, 0, 0, video.width, video.height); else if (mask == REDRAW_FIELD) - BlitBitmapTiled(background_bitmap_tile, gfx.background_bitmap, 0, 0, 0, 0, + BlitBitmapTiled(background_bitmap_tile, gfx.background_bitmap, + x, y, width, height, gfx.real_sx, gfx.real_sy, gfx.full_sxsize, gfx.full_sysize); else if (mask == REDRAW_DOOR_1) - BlitBitmapTiled(background_bitmap_tile, gfx.background_bitmap, 0, 0, 0, 0, + BlitBitmapTiled(background_bitmap_tile, gfx.background_bitmap, + x, y, width, height, gfx.dx, gfx.dy, gfx.dxsize, gfx.dysize); } -void SetWindowBackgroundBitmap(Bitmap *background_bitmap_tile) -{ - // remove every mask before setting mask for window - // (!!! TO BE FIXED: The whole REDRAW_* system really sucks! !!!) - SetBackgroundBitmap(NULL, 0xffff); // !!! FIX THIS !!! - SetBackgroundBitmap(background_bitmap_tile, REDRAW_ALL); -} - -void SetMainBackgroundBitmap(Bitmap *background_bitmap_tile) -{ - // remove window area mask before setting mask for main area - // (!!! TO BE FIXED: The whole REDRAW_* system really sucks! !!!) - SetBackgroundBitmap(NULL, REDRAW_ALL); // !!! FIX THIS !!! - SetBackgroundBitmap(background_bitmap_tile, REDRAW_FIELD); -} - -void SetDoorBackgroundBitmap(Bitmap *background_bitmap_tile) -{ - // remove window area mask before setting mask for door area - // (!!! TO BE FIXED: The whole REDRAW_* system really sucks! !!!) - SetBackgroundBitmap(NULL, REDRAW_ALL); // !!! FIX THIS !!! - SetBackgroundBitmap(background_bitmap_tile, REDRAW_DOOR_1); -} - // ============================================================================ // video functions diff --git a/src/libgame/system.h b/src/libgame/system.h index 524dbc58..5c131b97 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -1987,9 +1987,7 @@ boolean GetOverlayActive(void); void SetDrawDeactivationMask(int); int GetDrawDeactivationMask(void); void SetDrawBackgroundMask(int); -void SetWindowBackgroundBitmap(Bitmap *); -void SetMainBackgroundBitmap(Bitmap *); -void SetDoorBackgroundBitmap(Bitmap *); +void SetBackgroundBitmap(Bitmap *, int, int, int, int, int); void SetRedrawMaskFromArea(int, int, int, int); void LimitScreenUpdates(boolean); diff --git a/src/main.c b/src/main.c index cf51e039..d6bc2d26 100644 --- a/src/main.c +++ b/src/main.c @@ -21,7 +21,6 @@ #include "config.h" Bitmap *bitmap_db_field; -Bitmap *bitmap_db_panel; Bitmap *bitmap_db_door_1; Bitmap *bitmap_db_door_2; Bitmap *bitmap_db_store_1; diff --git a/src/main.h b/src/main.h index e111f027..238a0774 100644 --- a/src/main.h +++ b/src/main.h @@ -3762,7 +3762,6 @@ struct HelpAnimInfo extern Bitmap *bitmap_db_field; -extern Bitmap *bitmap_db_panel; extern Bitmap *bitmap_db_door_1; extern Bitmap *bitmap_db_door_2; extern Bitmap *bitmap_db_store_1; diff --git a/src/tools.c b/src/tools.c index d9e3652c..4ebf19bb 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1110,26 +1110,25 @@ static int getGlobalGameStatus(int status) status); } -Bitmap *getBitmapFromGraphicOrDefault(int graphic, int default_graphic) +int getImageFromGraphicOrDefault(int graphic, int default_graphic) { if (graphic == IMG_UNDEFINED) - return NULL; + return IMG_UNDEFINED; boolean redefined = getImageListEntryFromImageID(graphic)->redefined; return (graphic_info[graphic].bitmap != NULL || redefined ? - graphic_info[graphic].bitmap : - graphic_info[default_graphic].bitmap); + graphic : default_graphic); } -static Bitmap *getBackgroundBitmap(int graphic) +static int getBackgroundImage(int graphic) { - return getBitmapFromGraphicOrDefault(graphic, IMG_BACKGROUND); + return getImageFromGraphicOrDefault(graphic, IMG_BACKGROUND); } -static Bitmap *getGlobalBorderBitmap(int graphic) +static int getGlobalBorderImage(int graphic) { - return getBitmapFromGraphicOrDefault(graphic, IMG_GLOBAL_BORDER); + return getImageFromGraphicOrDefault(graphic, IMG_GLOBAL_BORDER); } Bitmap *getGlobalBorderBitmapFromStatus(int status_raw) @@ -1141,51 +1140,66 @@ Bitmap *getGlobalBorderBitmapFromStatus(int status_raw) status == GAME_MODE_EDITOR ? IMG_GLOBAL_BORDER_EDITOR : status == GAME_MODE_PLAYING ? IMG_GLOBAL_BORDER_PLAYING : IMG_GLOBAL_BORDER); + int graphic_final = getGlobalBorderImage(graphic); - return getGlobalBorderBitmap(graphic); + return graphic_info[graphic_final].bitmap; +} + +void SetBackgroundImage(int graphic, int redraw_mask) +{ + struct GraphicInfo *g = &graphic_info[graphic]; + struct GraphicInfo g_undefined = { 0 }; + + if (graphic == IMG_UNDEFINED) + g = &g_undefined; + + // remove every mask before setting mask for window, and + // remove window area mask before setting mask for main or door area + int remove_mask = (redraw_mask == REDRAW_ALL ? 0xffff : REDRAW_ALL); + + // (!!! TO BE FIXED: The whole REDRAW_* system really sucks! !!!) + SetBackgroundBitmap(NULL, remove_mask, 0, 0, 0, 0); // !!! FIX THIS !!! + SetBackgroundBitmap(g->bitmap, redraw_mask, + g->src_x, g->src_y, + g->width, g->height); } void SetWindowBackgroundImageIfDefined(int graphic) { if (graphic_info[graphic].bitmap) - SetWindowBackgroundBitmap(graphic_info[graphic].bitmap); + SetBackgroundImage(graphic, REDRAW_ALL); } void SetMainBackgroundImageIfDefined(int graphic) { if (graphic_info[graphic].bitmap) - SetMainBackgroundBitmap(graphic_info[graphic].bitmap); + SetBackgroundImage(graphic, REDRAW_FIELD); } void SetDoorBackgroundImageIfDefined(int graphic) { if (graphic_info[graphic].bitmap) - SetDoorBackgroundBitmap(graphic_info[graphic].bitmap); + SetBackgroundImage(graphic, REDRAW_DOOR_1); } void SetWindowBackgroundImage(int graphic) { - SetWindowBackgroundBitmap(getBackgroundBitmap(graphic)); + SetBackgroundImage(getBackgroundImage(graphic), REDRAW_ALL); } void SetMainBackgroundImage(int graphic) { - SetMainBackgroundBitmap(getBackgroundBitmap(graphic)); + SetBackgroundImage(getBackgroundImage(graphic), REDRAW_FIELD); } void SetDoorBackgroundImage(int graphic) { - SetDoorBackgroundBitmap(getBackgroundBitmap(graphic)); + SetBackgroundImage(getBackgroundImage(graphic), REDRAW_DOOR_1); } void SetPanelBackground(void) { - struct GraphicInfo *gfx = &graphic_info[IMG_BACKGROUND_PANEL]; - - BlitBitmapTiled(gfx->bitmap, bitmap_db_panel, gfx->src_x, gfx->src_y, - gfx->width, gfx->height, 0, 0, DXSIZE, DYSIZE); - - SetDoorBackgroundBitmap(bitmap_db_panel); + SetDoorBackgroundImage(IMG_BACKGROUND_PANEL); } void DrawBackground(int x, int y, int width, int height) diff --git a/src/tools.h b/src/tools.h index 395e73b9..e0c4726d 100644 --- a/src/tools.h +++ b/src/tools.h @@ -108,10 +108,12 @@ void FadeSetDisabled(void); void FadeSkipNextFadeIn(void); void FadeSkipNextFadeOut(void); -Bitmap *getBitmapFromGraphicOrDefault(int, int); +int getImageFromGraphicOrDefault(int, int); Bitmap *getGlobalBorderBitmapFromStatus(int); void ClearField(void); + +void SetBackgroundImage(int, int); void SetWindowBackgroundImageIfDefined(int); void SetMainBackgroundImageIfDefined(int); void SetDoorBackgroundImageIfDefined(int);