From: Holger Schemel Date: Wed, 9 Dec 2020 22:37:16 +0000 (+0100) Subject: moved function to different source file X-Git-Tag: 4.2.1.0~64 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=7fde4f8890072581071022bf530a84d7317b739b moved function to different source file --- diff --git a/src/engines.h b/src/engines.h index 826ad964..34838d5a 100644 --- a/src/engines.h +++ b/src/engines.h @@ -61,6 +61,7 @@ int el2img_mm(int); void CheckSingleStepMode_MM(boolean, boolean); +int getGraphicAnimationFrame(int, int); void getGraphicSource(int, int, Bitmap **, int *, int *); void getMiniGraphicSource(int, Bitmap **, int *, int *); void getSizedGraphicSource(int, int, int, Bitmap **, int *, int *); diff --git a/src/game_mm/export.h b/src/game_mm/export.h index 6625c848..4a63b249 100644 --- a/src/game_mm/export.h +++ b/src/game_mm/export.h @@ -222,6 +222,7 @@ void InitGameActions_MM(void); void GameActions_MM(struct MouseActionInfo, boolean); void DrawLaser_MM(void); +void DrawTileCursor_MM(int, boolean); boolean ClickElement(int, int, int); diff --git a/src/game_mm/mm_tools.c b/src/game_mm/mm_tools.c index c104791c..ae20aa24 100644 --- a/src/game_mm/mm_tools.c +++ b/src/game_mm/mm_tools.c @@ -626,6 +626,62 @@ void DrawMiniLevel_MM(int size_x, int size_y, int scroll_x, int scroll_y) redraw_mask |= REDRAW_FIELD; } +void DrawTileCursor_MM(int draw_target, boolean tile_cursor_active) +{ + Bitmap *fade_bitmap; + Bitmap *src_bitmap; + int src_x, src_y; + int dst_x, dst_y; + int graphic = IMG_GLOBAL_TILE_CURSOR; + int frame = 0; + int tilesize = TILESIZE_VAR; + int width = tilesize; + int height = tilesize; + + if (!tile_cursor.enabled || + !tile_cursor.active || + !tile_cursor_active) + return; + + if (tile_cursor.moving) + { + int step = TILESIZE_VAR / 4; + int dx = tile_cursor.target_x - tile_cursor.x; + int dy = tile_cursor.target_y - tile_cursor.y; + + if (ABS(dx) < step) + tile_cursor.x = tile_cursor.target_x; + else + tile_cursor.x += SIGN(dx) * step; + + if (ABS(dy) < step) + tile_cursor.y = tile_cursor.target_y; + else + tile_cursor.y += SIGN(dy) * step; + + if (tile_cursor.x == tile_cursor.target_x && + tile_cursor.y == tile_cursor.target_y) + tile_cursor.moving = FALSE; + } + + dst_x = tile_cursor.x; + dst_y = tile_cursor.y; + + frame = getGraphicAnimationFrame(graphic, -1); + + getSizedGraphicSource(graphic, frame, tilesize, &src_bitmap, &src_x, &src_y); + + fade_bitmap = + (draw_target == DRAW_TO_FADE_SOURCE ? gfx.fade_bitmap_source : + draw_target == DRAW_TO_FADE_TARGET ? gfx.fade_bitmap_target : NULL); + + if (draw_target == DRAW_TO_SCREEN) + BlitToScreenMasked(src_bitmap, src_x, src_y, width, height, dst_x, dst_y); + else + BlitBitmapMasked(src_bitmap, fade_bitmap, src_x, src_y, width, height, + dst_x, dst_y); +} + #if 0 static int REQ_in_range(int x, int y) { diff --git a/src/game_mm/mm_tools.h b/src/game_mm/mm_tools.h index e4c97416..97b48f43 100644 --- a/src/game_mm/mm_tools.h +++ b/src/game_mm/mm_tools.h @@ -94,6 +94,7 @@ void DrawWalls_MM(int, int, int); void DrawWallsAnimation_MM(int, int, int, int, int); void DrawMiniLevel_MM(int, int, int, int); void DrawMicroLevel_MM(int, int, boolean); +void DrawTileCursor_MM(int, boolean); boolean Request(char *, unsigned int); unsigned int OpenDoor(unsigned int); diff --git a/src/tools.c b/src/tools.c index 29254bb7..27469503 100644 --- a/src/tools.c +++ b/src/tools.c @@ -616,60 +616,7 @@ void DrawMaskedBorderToTarget(int draw_target) void DrawTileCursor(int draw_target) { - Bitmap *fade_bitmap; - Bitmap *src_bitmap; - int src_x, src_y; - int dst_x, dst_y; - int graphic = IMG_GLOBAL_TILE_CURSOR; - int frame = 0; - int tilesize = TILESIZE_VAR; - int width = tilesize; - int height = tilesize; - - if (game_status != GAME_MODE_PLAYING) - return; - - if (!tile_cursor.enabled || - !tile_cursor.active) - return; - - if (tile_cursor.moving) - { - int step = TILESIZE_VAR / 4; - int dx = tile_cursor.target_x - tile_cursor.x; - int dy = tile_cursor.target_y - tile_cursor.y; - - if (ABS(dx) < step) - tile_cursor.x = tile_cursor.target_x; - else - tile_cursor.x += SIGN(dx) * step; - - if (ABS(dy) < step) - tile_cursor.y = tile_cursor.target_y; - else - tile_cursor.y += SIGN(dy) * step; - - if (tile_cursor.x == tile_cursor.target_x && - tile_cursor.y == tile_cursor.target_y) - tile_cursor.moving = FALSE; - } - - dst_x = tile_cursor.x; - dst_y = tile_cursor.y; - - frame = getGraphicAnimationFrame(graphic, -1); - - getSizedGraphicSource(graphic, frame, tilesize, &src_bitmap, &src_x, &src_y); - - fade_bitmap = - (draw_target == DRAW_TO_FADE_SOURCE ? gfx.fade_bitmap_source : - draw_target == DRAW_TO_FADE_TARGET ? gfx.fade_bitmap_target : NULL); - - if (draw_target == DRAW_TO_SCREEN) - BlitToScreenMasked(src_bitmap, src_x, src_y, width, height, dst_x, dst_y); - else - BlitBitmapMasked(src_bitmap, fade_bitmap, src_x, src_y, width, height, - dst_x, dst_y); + DrawTileCursor_MM(draw_target, game_status == GAME_MODE_PLAYING); } void BlitScreenToBitmapExt_RND(Bitmap *target_bitmap, int fx, int fy)