From: Holger Schemel Date: Sat, 18 Feb 2017 19:57:30 +0000 (+0100) Subject: fixed editor and preview wall graphics for Mirror Magic game engine X-Git-Tag: 4.1.0.0~209 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=0e571d5d795b7ab85fd0f57f0a9e71295dac86f2 fixed editor and preview wall graphics for Mirror Magic game engine --- diff --git a/src/main.h b/src/main.h index 8b09f5d9..845f4712 100644 --- a/src/main.h +++ b/src/main.h @@ -674,6 +674,20 @@ #define IS_INTERNAL_ELEMENT(e) ((e) >= EL_INTERNAL_START && \ (e) <= EL_INTERNAL_END) +#define IS_MM_ELEMENT(e) ((e) >= EL_MM_START && \ + (e) <= EL_MM_END) + +#define IS_DF_ELEMENT(e) ((e) >= EL_DF_START && \ + (e) <= EL_DF_END) + +#define IS_MM_WALL(e) (((e) >= EL_MM_WALL_START && \ + (e) <= EL_MM_WALL_END) || \ + ((e) >= EL_DF_WALL_START && \ + (e) <= EL_DF_WALL_END)) + +#define IS_DF_WALL(e) (((e) >= EL_DF_WALL_START && \ + (e) <= EL_DF_WALL_END)) + #define IS_ENVELOPE(e) ((e) >= EL_ENVELOPE_1 && \ (e) <= EL_ENVELOPE_4) diff --git a/src/tools.c b/src/tools.c index 165120c0..36545249 100644 --- a/src/tools.c +++ b/src/tools.c @@ -2446,12 +2446,47 @@ void DrawLevelField(int x, int y) } } +void DrawSizedWall_MM(int dst_x, int dst_y, int element, int tilesize, + int (*el2img_function)(int)) +{ + int element_base = map_mm_wall_element(element); + int element_bits = (IS_DF_WALL(element) ? + element - EL_DF_WALL_START : + element - EL_MM_WALL_START) & 0x000f; + int graphic = el2img_function(element_base); + int tilesize_draw = tilesize / 2; + Bitmap *src_bitmap; + int src_x, src_y; + int i; + + getSizedGraphicSource(graphic, 0, tilesize_draw, &src_bitmap, &src_x, &src_y); + + for (i = 0; i < 4; i++) + { + int dst_draw_x = dst_x + (i % 2) * tilesize_draw; + int dst_draw_y = dst_y + (i / 2) * tilesize_draw; + + if (element_bits & (1 << i)) + BlitBitmap(src_bitmap, drawto, src_x, src_y, tilesize_draw, tilesize_draw, + dst_draw_x, dst_draw_y); + else + ClearRectangle(drawto, dst_x, dst_y, tilesize_draw, tilesize_draw); + } +} + void DrawSizedElement(int x, int y, int element, int tilesize) { - int graphic; + if (IS_MM_WALL(element)) + { + DrawSizedWall_MM(SX + x * tilesize, SY + y * tilesize, + element, tilesize, el2edimg); + } + else + { + int graphic = el2edimg(element); - graphic = el2edimg(element); - DrawSizedGraphic(x, y, graphic, 0, tilesize); + DrawSizedGraphic(x, y, graphic, 0, tilesize); + } } void DrawMiniElement(int x, int y, int element) @@ -2961,12 +2996,20 @@ void ShowEnvelopeRequest(char *text, unsigned int req_state, int action) void DrawPreviewElement(int dst_x, int dst_y, int element, int tilesize) { - Bitmap *src_bitmap; - int src_x, src_y; - int graphic = el2preimg(element); + if (IS_MM_WALL(element)) + { + DrawSizedWall_MM(dst_x, dst_y, element, tilesize, el2preimg); + } + else + { + Bitmap *src_bitmap; + int src_x, src_y; + int graphic = el2preimg(element); - getSizedGraphicSource(graphic, 0, tilesize, &src_bitmap, &src_x, &src_y); - BlitBitmap(src_bitmap, drawto, src_x, src_y, tilesize, tilesize, dst_x,dst_y); + getSizedGraphicSource(graphic, 0, tilesize, &src_bitmap, &src_x, &src_y); + BlitBitmap(src_bitmap, drawto, src_x, src_y, tilesize, tilesize, + dst_x, dst_y); + } } void DrawLevel(int draw_background_mask) @@ -7282,6 +7325,35 @@ int map_element_MM_to_RND(int element_mm) EL_EMPTY); } +int map_mm_wall_element(int element) +{ + return (element >= EL_MM_STEEL_WALL_START && + element <= EL_MM_STEEL_WALL_END ? + EL_MM_STEEL_WALL : + + element >= EL_MM_WOODEN_WALL_START && + element <= EL_MM_WOODEN_WALL_END ? + EL_MM_WOODEN_WALL : + + element >= EL_MM_ICE_WALL_START && + element <= EL_MM_ICE_WALL_END ? + EL_MM_ICE_WALL : + + element >= EL_MM_AMOEBA_WALL_START && + element <= EL_MM_AMOEBA_WALL_END ? + EL_MM_AMOEBA_WALL : + + element >= EL_DF_STEEL_WALL_START && + element <= EL_DF_STEEL_WALL_END ? + EL_DF_STEEL_WALL : + + element >= EL_DF_WOODEN_WALL_START && + element <= EL_DF_WOODEN_WALL_END ? + EL_DF_WOODEN_WALL : + + element); +} + int get_next_element(int element) { switch (element) diff --git a/src/tools.h b/src/tools.h index cdee2635..7af465eb 100644 --- a/src/tools.h +++ b/src/tools.h @@ -221,6 +221,7 @@ int map_action_SP_to_RND(int); int map_element_RND_to_MM(int); int map_element_MM_to_RND(int); +int map_mm_wall_element(int); int get_next_element(int); int el_act_dir2img(int, int, int);