From 7d85a53b341ca7a3dca87b6f2ccebf45ddf96c92 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Tue, 10 Apr 2018 21:44:08 +0200 Subject: [PATCH] fixed tile selection cursor position for levels smaller than the playfield For centered levels that are smaller than the playfield (MM engine), the tile selection cursor position was not shifted like the level, but was still inside the top/left aligned grid as if the level was not centered. This fix also centers the tile selection cursor position accordingly. --- src/game_mm/mm_tools.c | 2 ++ src/libgame/system.c | 13 +++++++++++-- src/libgame/system.h | 3 +++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/game_mm/mm_tools.c b/src/game_mm/mm_tools.c index 1a27d91a..a5cd79da 100644 --- a/src/game_mm/mm_tools.c +++ b/src/game_mm/mm_tools.c @@ -37,6 +37,8 @@ void SetDrawtoField_MM(int mode) cFX = FX + dSX; cFY = FY + dSY; } + + SetTileCursorSXSY(cSX, cSY); } void ClearWindow() diff --git a/src/libgame/system.c b/src/libgame/system.c index a35f91d6..139ee57a 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -318,6 +318,9 @@ void InitTileCursorInfo() tile_cursor.y = 0; tile_cursor.target_x = 0; tile_cursor.target_y = 0; + + tile_cursor.sx = 0; + tile_cursor.sy = 0; } void InitOverlayInfo() @@ -348,8 +351,8 @@ void SetTileCursorTargetXY(int x, int y) tile_cursor.xpos = x; 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.target_x = tile_cursor.sx + x * gfx.game_tile_size; + tile_cursor.target_y = tile_cursor.sy + y * gfx.game_tile_size; tile_cursor.moving = TRUE; } @@ -366,6 +369,12 @@ void SetTileCursorXY(int x, int y) tile_cursor.moving = FALSE; } +void SetTileCursorSXSY(int sx, int sy) +{ + tile_cursor.sx = sx; + tile_cursor.sy = sy; +} + void SetOverlayEnabled(boolean enabled) { overlay.enabled = enabled; diff --git a/src/libgame/system.h b/src/libgame/system.h index 7f8d2341..f3da4ad1 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -963,6 +963,8 @@ struct TileCursorInfo int xpos, ypos; /* tile cursor level playfield position */ int x, y; /* tile cursor current screen position */ int target_x, target_y; /* tile cursor target screen position */ + + int sx, sy; /* tile cursor screen start position */ }; struct OverlayInfo @@ -1534,6 +1536,7 @@ void SetTileCursorEnabled(boolean); void SetTileCursorActive(boolean); void SetTileCursorTargetXY(int, int); void SetTileCursorXY(int, int); +void SetTileCursorSXSY(int, int); void SetOverlayEnabled(boolean); void SetOverlayActive(boolean); boolean GetOverlayActive(); -- 2.34.1