X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fscreens.c;h=236361866c8f39fa7256e8ae5c4f4527d12b540c;hp=4802015c8fe1519456267c76133a700c2cac65fb;hb=6a4e096460bdde9baf30f95a4da109355ceb849f;hpb=357f4970ed173c97267960ce5c96f585dd1b5b32 diff --git a/src/screens.c b/src/screens.c index 4802015c..23636186 100644 --- a/src/screens.c +++ b/src/screens.c @@ -1184,6 +1184,17 @@ static boolean insideTextPosRect(struct TextPosInfo *rect, int x, int y) y >= rect_y && y < rect_y + rect->height); } +static boolean insidePreviewRect(struct PreviewInfo *preview, int x, int y) +{ + int rect_width = preview->xsize * preview->tile_size; + int rect_height = preview->ysize * preview->tile_size; + int rect_x = ALIGNED_XPOS(preview->x, rect_width, preview->align); + int rect_y = ALIGNED_YPOS(preview->y, rect_height, preview->valign); + + return (x >= rect_x && x < rect_x + rect_width && + y >= rect_y && y < rect_y + rect_height); +} + static void AdjustScrollbar(int id, int items_max, int items_visible, int item_position) { @@ -1807,6 +1818,10 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) } } + /* check if level preview was clicked */ + if (insidePreviewRect(&preview, mx - SX, my - SY)) + pos = MAIN_CONTROL_GAME; + // handle pressed/unpressed state for active/inactive menu buttons // (if pos != -1, "i" contains index position corresponding to "pos") if (button &&