From de9f167f6960194e913af2a768456d502d4fdf1a Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Fri, 15 Dec 2017 08:19:27 +0100 Subject: [PATCH] fixed moving tile selection cursor --- src/events.c | 2 +- src/libgame/system.c | 5 +++++ src/libgame/system.h | 1 + src/tools.c | 9 ++++++--- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/events.c b/src/events.c index 84652764..5dabff98 100644 --- a/src/events.c +++ b/src/events.c @@ -2187,7 +2187,7 @@ static void HandleTileCursor(int dx, int dy, int button) (dx < 0 ? MB_LEFTBUTTON : dx > 0 ? MB_RIGHTBUTTON : MB_RELEASED)); } - else + else if (!tile_cursor.moving) { int old_xpos = tile_cursor.xpos; int old_ypos = tile_cursor.ypos; diff --git a/src/libgame/system.c b/src/libgame/system.c index dea7258d..a35f91d6 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -310,6 +310,7 @@ void InitTileCursorInfo() { tile_cursor.enabled = FALSE; tile_cursor.active = FALSE; + tile_cursor.moving = FALSE; tile_cursor.xpos = 0; tile_cursor.ypos = 0; @@ -349,6 +350,8 @@ void SetTileCursorTargetXY(int x, int y) tile_cursor.ypos = y; tile_cursor.target_x = gfx.sx + x * gfx.game_tile_size; tile_cursor.target_y = gfx.sy + y * gfx.game_tile_size; + + tile_cursor.moving = TRUE; } void SetTileCursorXY(int x, int y) @@ -359,6 +362,8 @@ void SetTileCursorXY(int x, int y) tile_cursor.x = tile_cursor.target_x; tile_cursor.y = tile_cursor.target_y; + + tile_cursor.moving = FALSE; } void SetOverlayEnabled(boolean enabled) diff --git a/src/libgame/system.h b/src/libgame/system.h index a2226a78..578d060e 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -958,6 +958,7 @@ struct TileCursorInfo { boolean enabled; /* tile cursor generally enabled or disabled */ boolean active; /* tile cursor activated (depending on game) */ + boolean moving; /* tile cursor moving to target position */ int xpos, ypos; /* tile cursor level playfield position */ int x, y; /* tile cursor current screen position */ diff --git a/src/tools.c b/src/tools.c index 3c301a39..d11d99d2 100644 --- a/src/tools.c +++ b/src/tools.c @@ -654,10 +654,9 @@ void DrawTileCursor(int draw_target) !tile_cursor.active) return; - if (tile_cursor.x != tile_cursor.target_x || - tile_cursor.y != tile_cursor.target_y) + if (tile_cursor.moving) { - int step = TILESIZE_VAR / (GADGET_FRAME_DELAY / video.frame_delay_value); + int step = TILESIZE_VAR / 4; int dx = tile_cursor.target_x - tile_cursor.x; int dy = tile_cursor.target_y - tile_cursor.y; @@ -670,6 +669,10 @@ void DrawTileCursor(int draw_target) 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; -- 2.34.1