X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fscreens.c;h=0bd9af8403d35c5a2de0cbdc3fb445a98d603b0b;hp=a6c7e0a635e7eb098163ba0e8dc1732a8e7e0d02;hb=14d7691c65ca4a466ce9b9448153e8fbe8351a81;hpb=36fdadd45345a6ce4402fa3bdbb3b12b4cbb62ee diff --git a/src/screens.c b/src/screens.c index a6c7e0a6..0bd9af84 100644 --- a/src/screens.c +++ b/src/screens.c @@ -411,12 +411,18 @@ static struct menu.list_size[game_status] : \ MAX_MENU_ENTRIES_ON_SCREEN) +#define IN_VIS_MENU(x, y) IN_FIELD(x, y, SCR_FIELDX, \ + NUM_MENU_ENTRIES_ON_SCREEN) + /* title display and control definitions */ #define MAX_NUM_TITLE_SCREENS (2 * MAX_NUM_TITLE_IMAGES + \ 2 * MAX_NUM_TITLE_MESSAGES) +#define NO_DIRECT_LEVEL_SELECT (-1) + + static int num_title_screens = 0; struct TitleControlInfo @@ -1218,10 +1224,7 @@ void DrawTitleScreenImage(int nr, boolean initial) ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE); if (DrawingOnBackground(dst_x, dst_y)) - { - SetClipOrigin(bitmap, bitmap->stored_clip_gc, dst_x - src_x, dst_y - src_y); BlitBitmapMasked(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y); - } else BlitBitmap(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y); @@ -1629,12 +1632,16 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) } } -void HandleMainMenu_SelectLevel(int step, int direction) +void HandleMainMenu_SelectLevel(int step, int direction, int selected_level_nr) { int old_level_nr = level_nr; int new_level_nr; - new_level_nr = old_level_nr + step * direction; + if (selected_level_nr != NO_DIRECT_LEVEL_SELECT) + new_level_nr = selected_level_nr; + else + new_level_nr = old_level_nr + step * direction; + if (new_level_nr < leveldir_current->first_level) new_level_nr = leveldir_current->first_level; if (new_level_nr > leveldir_current->last_level) @@ -1643,7 +1650,7 @@ void HandleMainMenu_SelectLevel(int step, int direction) if (setup.handicap && new_level_nr > leveldir_current->handicap_level) { /* skipping levels is only allowed when trying to skip single level */ - if (setup.skip_levels && step == 1 && + if (setup.skip_levels && new_level_nr == old_level_nr + 1 && Request("Level still unsolved! Skip despite handicap?", REQ_ASK)) { leveldir_current->handicap_level++; @@ -1674,7 +1681,7 @@ void HandleMainMenu_SelectLevel(int step, int direction) /* needed because DrawPreviewLevelInitial() takes some time */ BackToFront(); - SyncDisplay(); + /* SyncDisplay(); */ } } @@ -1718,15 +1725,15 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) if (pos == MAIN_CONTROL_LEVELS && dx != 0 && button) { - HandleMainMenu_SelectLevel(1, dx < 0 ? -1 : +1); + HandleMainMenu_SelectLevel(1, (dx < 0 ? -1 : +1), NO_DIRECT_LEVEL_SELECT); } else if (pos == MAIN_CONTROL_FIRST_LEVEL && !button) { - HandleMainMenu_SelectLevel(MAX_LEVELS, -1); + HandleMainMenu_SelectLevel(MAX_LEVELS, -1, NO_DIRECT_LEVEL_SELECT); } else if (pos == MAIN_CONTROL_LAST_LEVEL && !button) { - HandleMainMenu_SelectLevel(MAX_LEVELS, +1); + HandleMainMenu_SelectLevel(MAX_LEVELS, +1, NO_DIRECT_LEVEL_SELECT); } else if (pos == MAIN_CONTROL_LEVEL_NUMBER && !button) { @@ -2046,7 +2053,7 @@ void HandleInfoScreen_Main(int mx, int my, int dx, int dy, int button) y += dy; } - if (IN_VIS_FIELD(x, y) && + if (IN_VIS_MENU(x, y) && y >= 0 && y < num_info_info && info_info[y].type & ~TYPE_SKIP_ENTRY) { if (button) @@ -2620,7 +2627,7 @@ static void DrawInfoScreen_CreditsScreen(int screen_nr) DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2, "and"); DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3, - "Jürgen Bonhagen"); + "J\xfcrgen Bonhagen"); DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2, "for the continuous creation"); DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_2, @@ -2674,7 +2681,7 @@ static void DrawInfoScreen_CreditsScreen(int screen_nr) DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2, "Thanks to"); DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3, - "Karl Hörnell"); + "Karl H\xf6rnell"); DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2, "for some additional toons"); } @@ -3260,6 +3267,19 @@ static void AdjustChooseTreeScrollbar(int id, int first_entry, TreeInfo *ti) first_entry); } +static void clearMenuListArea() +{ + int scrollbar_xpos = mSX + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset; + + /* correct scrollbar position if placed outside menu (playfield) area */ + if (scrollbar_xpos > SC_SCROLLBAR_XPOS) + scrollbar_xpos = SC_SCROLLBAR_XPOS; + + /* clear menu list area, but not title or scrollbar */ + DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32, + scrollbar_xpos - mSX, NUM_MENU_ENTRIES_ON_SCREEN * 32); +} + static void drawChooseTreeList(int first_entry, int num_page_entries, TreeInfo *ti) { @@ -3275,10 +3295,7 @@ static void drawChooseTreeList(int first_entry, int num_page_entries, DrawTextSCentered(mSY - SY + yoffset, FONT_TITLE_1, title_string); - /* clear tree list area, but not title or scrollbar */ - DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32, - SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset, - NUM_MENU_ENTRIES_ON_SCREEN * 32); + clearMenuListArea(); for (i = 0; i < num_page_entries; i++) { @@ -3437,7 +3454,11 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, else { if (game_status == GAME_MODE_LEVELNR) - level_nr = atoi(level_number_current->identifier); + { + int new_level_nr = atoi(level_number_current->identifier); + + HandleMainMenu_SelectLevel(0, 0, new_level_nr); + } game_status = GAME_MODE_MAIN; @@ -3548,7 +3569,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, } if (!anyScrollbarGadgetActive() && - IN_VIS_FIELD(x, y) && + IN_VIS_MENU(x, y) && mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x && y >= 0 && y < num_page_entries) { @@ -3631,7 +3652,11 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, else { if (game_status == GAME_MODE_LEVELNR) - level_nr = atoi(level_number_current->identifier); + { + int new_level_nr = atoi(level_number_current->identifier); + + HandleMainMenu_SelectLevel(0, 0, new_level_nr); + } game_status = GAME_MODE_MAIN; @@ -5231,10 +5256,7 @@ static void drawSetupInfoList(struct TokenInfo *setup_info, if (first_entry + num_page_entries > max_setup_info) first_entry = 0; - /* clear tree list area, but not title or scrollbar */ - DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32, - SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset, - NUM_MENU_ENTRIES_ON_SCREEN * 32); + clearMenuListArea(); for (i = 0; i < num_page_entries; i++) { @@ -5553,7 +5575,7 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button) setup_info[first_entry + y].type & TYPE_SKIP_ENTRY) y += dy; - if (!IN_VIS_FIELD(x, y)) + if (!IN_VIS_MENU(x, y)) { choice += y - y_old; @@ -5587,7 +5609,7 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button) } if (!anyScrollbarGadgetActive() && - IN_VIS_FIELD(x, y) && + IN_VIS_MENU(x, y) && mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x && y >= 0 && y < num_page_entries) { @@ -5850,7 +5872,7 @@ void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button) { HandleSetupScreen_Input_Player(1, dx < 0 ? -1 : +1); } - else if (IN_VIS_FIELD(x, y) && + else if (IN_VIS_FIELD(x, y) && // (does not use "IN_VIS_MENU()" yet) y >= pos_start && y <= pos_end && !(y >= pos_empty1 && y <= pos_empty2)) { @@ -6545,6 +6567,10 @@ static void CreateScreenScrollbuttons() width = SC_SCROLLBUTTON_XSIZE; height = SC_SCROLLBUTTON_YSIZE; + /* correct scrollbar position if placed outside menu (playfield) area */ + if (x > SC_SCROLL_UP_XPOS) + x = SC_SCROLL_UP_XPOS; + if (id == SCREEN_CTRL_ID_SCROLL_DOWN) y = mSY + (SC_SCROLL_VERTICAL_YPOS + (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE); @@ -6610,6 +6636,10 @@ static void CreateScreenScrollbars() width = scrollbar_info[i].width; height = scrollbar_info[i].height; + /* correct scrollbar position if placed outside menu (playfield) area */ + if (x > SC_SCROLL_VERTICAL_XPOS) + x = SC_SCROLL_VERTICAL_XPOS; + if (id == SCREEN_CTRL_ID_SCROLL_VERTICAL) height = (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE; @@ -6714,11 +6744,11 @@ static void HandleScreenGadgets(struct GadgetInfo *gi) switch (id) { case SCREEN_CTRL_ID_PREV_LEVEL: - HandleMainMenu_SelectLevel(step, -1); + HandleMainMenu_SelectLevel(step, -1, NO_DIRECT_LEVEL_SELECT); break; case SCREEN_CTRL_ID_NEXT_LEVEL: - HandleMainMenu_SelectLevel(step, +1); + HandleMainMenu_SelectLevel(step, +1, NO_DIRECT_LEVEL_SELECT); break; case SCREEN_CTRL_ID_PREV_PLAYER: