X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fscreens.c;h=d38878c320e33c53c66577debb3b1148b1bfa6b5;hp=66f863cce57fc97b3f99b4cc63bf69f52f7d5174;hb=6c674ccdd458314ced75459649c6acf1489b6056;hpb=00ca5a80f980e039d78ed670e88f88a85d222461 diff --git a/src/screens.c b/src/screens.c index 66f863cc..d38878c3 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 && @@ -3570,9 +3585,7 @@ void HandleTypeName(int newxpos, Key key) xpos = newxpos; -#if defined(TARGET_SDL2) - SDL_StartTextInput(); -#endif + StartTextInput(startx, starty); } else if (is_valid_key_char && xpos < MAX_PLAYER_NAME_LEN) { @@ -3619,9 +3632,7 @@ void HandleTypeName(int newxpos, Key key) DrawText(startx, starty, setup.player_name, font_nr); -#if defined(TARGET_SDL2) - SDL_StopTextInput(); -#endif + StopTextInput(); } } @@ -3656,10 +3667,11 @@ static void DrawChooseTree(TreeInfo **ti_ptr) /* needed if different viewport properties defined for choosing level (set) */ ChangeViewportPropertiesIfNeeded(); - SetMainBackgroundImage(game_status == GAME_MODE_LEVELNR ? - IMG_BACKGROUND_LEVELNR : - game_status == GAME_MODE_LEVELS ? - IMG_BACKGROUND_LEVELS : IMG_BACKGROUND); + if (game_status == GAME_MODE_LEVELNR) + SetMainBackgroundImage(IMG_BACKGROUND_LEVELNR); + else if (game_status == GAME_MODE_LEVELS) + SetMainBackgroundImage(IMG_BACKGROUND_LEVELS); + ClearField(); OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);