X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fscreens.c;h=d096d3bb5ec12162b1e7d7a4c0fcd5b4d1d3226f;hb=bc8503fee1600305a9e915da07d5f2c29d9890b6;hp=950f4c8c067ea454c0c6af4bca085d9dfa67752c;hpb=6c54b168b94ebbd1fb1b44ce7bbfc671d3326cb4;p=rocksndiamonds.git diff --git a/src/screens.c b/src/screens.c index 950f4c8c..d096d3bb 100644 --- a/src/screens.c +++ b/src/screens.c @@ -78,6 +78,10 @@ static int setup_mode = SETUP_MODE_MAIN; game_status <= GAME_MODE_SETUP ? \ menu.draw_yoffset[game_status] : menu.draw_yoffset_default)) +#define NUM_MENU_ENTRIES_ON_SCREEN (menu.list_size[game_status] > 2 ? \ + menu.list_size[game_status] : \ + MAX_MENU_ENTRIES_ON_SCREEN) + #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND) #define NUM_SCROLLBAR_BITMAPS 2 static Bitmap *scrollbar_bitmap[NUM_SCROLLBAR_BITMAPS]; @@ -123,6 +127,18 @@ static void drawCursorXY(int xpos, int ypos, int graphic) drawCursorExt(xpos, ypos, -1, graphic); } +static void drawChooseTreeCursor(int ypos, int color) +{ + int last_game_status = game_status; /* save current game status */ + + /* force LEVELS draw offset on artwork setup screen */ + game_status = GAME_MODE_LEVELS; + + drawCursorExt(0, ypos, color, 0); + + game_status = last_game_status; /* restore current game status */ +} + static void PlaySound_Menu_Start(int sound) { if (sound_info[sound].loop) @@ -181,6 +197,8 @@ void DrawMainMenu() int level_width = font_width * strlen("Level:"); int i; + printf("::: CHECK A: '%s'\n", leveldir_current->graphics_path); + UnmapAllGadgets(); FadeSounds(); @@ -206,9 +224,24 @@ void DrawMainMenu() /* needed if last screen was the setup screen and fullscreen state changed */ ToggleFullscreenIfNeeded(); + printf("::: CHECK B.1: '%s'\n", leveldir_current->graphics_path); + +#if 1 + /* leveldir_current may be invalid (level group, parent link) */ + if (!validLevelSeries(leveldir_current)) + leveldir_current = getFirstValidTreeInfoEntry(leveldir_last_valid); + + /* store valid level series information */ + leveldir_last_valid = leveldir_current; +#endif + + printf("::: CHECK B.2: '%s'\n", leveldir_current->graphics_path); + /* needed if last screen (level choice) changed graphics, sounds or music */ ReloadCustomArtwork(); + printf("::: CHECK C: '%s'\n", leveldir_current->graphics_path); + #ifdef TARGET_SDL SetDrawtoField(DRAW_BACKBUFFER); #endif @@ -216,12 +249,14 @@ void DrawMainMenu() /* map gadgets for main menu screen */ MapTapeButtons(); +#if 0 /* leveldir_current may be invalid (level group, parent link) */ if (!validLevelSeries(leveldir_current)) leveldir_current = getFirstValidTreeInfoEntry(leveldir_last_valid); /* store valid level series information */ leveldir_last_valid = leveldir_current; +#endif /* level_nr may have been set to value over handicap with level editor */ if (setup.handicap && level_nr > leveldir_current->handicap_level) @@ -290,6 +325,8 @@ static void gotoTopLevelDir() /* move upwards to top level directory */ while (leveldir_current->node_parent) { + printf("::: ---> '%s'\n", leveldir_current->graphics_path); + /* write a "path" into level tree for easy navigation to last level */ if (leveldir_current->node_parent->node_group->cl_first == -1) { @@ -298,10 +335,10 @@ static void gotoTopLevelDir() int num_page_entries; int cl_first, cl_cursor; - if (num_leveldirs <= MAX_MENU_ENTRIES_ON_SCREEN) + if (num_leveldirs <= NUM_MENU_ENTRIES_ON_SCREEN) num_page_entries = num_leveldirs; else - num_page_entries = MAX_MENU_ENTRIES_ON_SCREEN; + num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN; cl_first = MAX(0, leveldir_pos - num_page_entries + 1); cl_cursor = leveldir_pos - cl_first; @@ -311,7 +348,11 @@ static void gotoTopLevelDir() } leveldir_current = leveldir_current->node_parent; + + printf("::: +++> '%s'\n", leveldir_current->graphics_path); } + + printf("::: ===> '%s'\n", leveldir_current->graphics_path); } void HandleMainMenu(int mx, int my, int dx, int dy, int button) @@ -402,8 +443,12 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) SaveLevelSetup_LastSeries(); SaveLevelSetup_SeriesInfo(); + printf("::: CHECK C.1: '%s'\n", leveldir_current->graphics_path); + gotoTopLevelDir(); + printf("::: CHECK C.2: '%s'\n", leveldir_current->graphics_path); + DrawChooseLevel(); } } @@ -511,7 +556,7 @@ static int helpscreen_action[] = IMG_INVISIBLE_WALL, -1, HA_NEXT, - IMG_WALL_CRUMBLED, -1, HA_NEXT, + IMG_WALL_SLIPPERY, -1, HA_NEXT, IMG_FONT_GAME_INFO, -1, HA_NEXT, @@ -902,11 +947,15 @@ void DrawHelpScreenElAction(int start) i++; } +#if 1 + redraw_mask |= REDRAW_FIELD; +#else for(i=2; i<16; i++) { MarkTileDirty(0, i); MarkTileDirty(1, i); } +#endif FrameCounter++; } @@ -1177,6 +1226,10 @@ void HandleTypeName(int newxpos, Key key) static void DrawChooseTree(TreeInfo **ti_ptr) { UnmapAllGadgets(); + + FreeScreenGadgets(); + CreateScreenGadgets(); + CloseDoor(DOOR_CLOSE_2); ClearWindow(); @@ -1194,13 +1247,14 @@ static void AdjustChooseTreeScrollbar(int id, int first_entry, TreeInfo *ti) int items_max, items_visible, item_position; items_max = numTreeInfoInGroup(ti); - items_visible = MAX_MENU_ENTRIES_ON_SCREEN; + items_visible = NUM_MENU_ENTRIES_ON_SCREEN; item_position = first_entry; if (item_position > items_max - items_visible) item_position = items_max - items_visible; ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max, + GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible, GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END); } @@ -1294,21 +1348,36 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, int step = (button == 1 ? 1 : button == 2 ? 5 : 10); int num_entries = numTreeInfoInGroup(ti); int num_page_entries; + int last_game_status = game_status; /* save current game status */ + + /* force LEVELS draw offset on choose level and artwork setup screen */ + game_status = GAME_MODE_LEVELS; - if (num_entries <= MAX_MENU_ENTRIES_ON_SCREEN) + if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN) num_page_entries = num_entries; else - num_page_entries = MAX_MENU_ENTRIES_ON_SCREEN; + num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN; + + game_status = last_game_status; /* restore current game status */ if (button == MB_MENU_INITIALIZE) { + int num_entries = numTreeInfoInGroup(ti); int entry_pos = posTreeInfo(ti); if (ti->cl_first == -1) { + /* only on initialization */ + ti->cl_first = MAX(0, entry_pos - num_page_entries + 1); + ti->cl_cursor = entry_pos - ti->cl_first; + } + else if (ti->cl_cursor >= num_page_entries || + (num_entries > num_page_entries && + num_entries - ti->cl_first < num_page_entries)) + { + /* only after change of list size (by custom graphic configuration) */ ti->cl_first = MAX(0, entry_pos - num_page_entries + 1); - ti->cl_cursor = - entry_pos - ti->cl_first; + ti->cl_cursor = entry_pos - ti->cl_first; } if (dx == 999) /* first entry is set by scrollbar position */ @@ -1319,7 +1388,8 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, drawChooseTreeList(ti->cl_first, num_page_entries, ti); drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti); - drawCursor(ti->cl_cursor, FC_RED); + drawChooseTreeCursor(ti->cl_cursor, FC_RED); + return; } else if (button == MB_MENU_LEAVE) @@ -1344,8 +1414,15 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, if (mx || my) /* mouse input */ { + int last_game_status = game_status; /* save current game status */ + + /* force LEVELS draw offset on artwork setup screen */ + game_status = GAME_MODE_LEVELS; + x = (mx - mSX) / 32; y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS; + + game_status = last_game_status; /* restore current game status */ } else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */ { @@ -1373,7 +1450,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, drawChooseTreeList(ti->cl_first, num_page_entries, ti); drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti); - drawCursor(ti->cl_cursor, FC_RED); + drawChooseTreeCursor(ti->cl_cursor, FC_RED); AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, ti->cl_first, ti); } @@ -1387,7 +1464,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, drawChooseTreeList(ti->cl_first, num_page_entries, ti); drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti); - drawCursor(ti->cl_cursor, FC_RED); + drawChooseTreeCursor(ti->cl_cursor, FC_RED); AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, ti->cl_first, ti); } @@ -1413,6 +1490,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, node_cursor->cl_cursor = ti->cl_cursor; *ti_ptr = node_cursor->node_group; DrawChooseTree(ti_ptr); + return; } } @@ -1420,6 +1498,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, { *ti_ptr = ti->node_parent; DrawChooseTree(ti_ptr); + return; } @@ -1429,8 +1508,8 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, { if (y != ti->cl_cursor) { - drawCursor(y, FC_RED); - drawCursor(ti->cl_cursor, FC_BLUE); + drawChooseTreeCursor(y, FC_RED); + drawChooseTreeCursor(ti->cl_cursor, FC_BLUE); drawChooseTreeInfo(ti->cl_first + y, ti); ti->cl_cursor = y; } @@ -1532,7 +1611,7 @@ static void drawHallOfFameList(int first_entry, int highlight_position) DrawText(mSX + 80, mSY + 8, "Hall Of Fame", FONT_TITLE_1); DrawTextFCentered(46, FONT_TITLE_2, "HighScores of Level %d", level_nr); - for(i=0; i 0) { - if (first_entry + MAX_MENU_ENTRIES_ON_SCREEN < MAX_SCORE_ENTRIES) + if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN < MAX_SCORE_ENTRIES) { first_entry += step; - if (first_entry + MAX_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES) - first_entry = MAX(0, MAX_SCORE_ENTRIES - MAX_MENU_ENTRIES_ON_SCREEN); + if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES) + first_entry = MAX(0, MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN); drawHallOfFameList(first_entry, highlight_position); + return; } } @@ -1659,13 +1741,13 @@ static void execSetupSound() static void execSetupArtwork() { - /* needed if last screen (setup choice) changed graphics, sounds or music */ - ReloadCustomArtwork(); - setup.graphics_set = artwork.gfx_current->identifier; setup.sounds_set = artwork.snd_current->identifier; setup.music_set = artwork.mus_current->identifier; + /* needed if last screen (setup choice) changed graphics, sounds or music */ + ReloadCustomArtwork(); + /* needed for displaying artwork name instead of artwork identifier */ graphics_set_name = artwork.gfx_current->name; sounds_set_name = artwork.snd_current->name; @@ -1981,7 +2063,7 @@ static void DrawSetupScreen_Generic() DrawText(mSX + 16, mSY + 16, title_string, FONT_TITLE_1); num_setup_info = 0; - for(i=0; setup_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++) + for(i=0; setup_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++) { void *value_ptr = setup_info[i].value; int ypos = MENU_SCREEN_START_YPOS + i; @@ -2800,7 +2882,7 @@ static struct #else IMG_MENU_SCROLLBAR, IMG_MENU_SCROLLBAR_ACTIVE, #endif - SX + SC_SCROLL_VERTICAL_XPOS, SY + SC_SCROLL_VERTICAL_YPOS, + SC_SCROLL_VERTICAL_XPOS, SC_SCROLL_VERTICAL_YPOS, SC_SCROLL_VERTICAL_XSIZE, SC_SCROLL_VERTICAL_YSIZE, GD_TYPE_SCROLLBAR_VERTICAL, SCREEN_CTRL_ID_SCROLL_VERTICAL, @@ -2822,16 +2904,17 @@ static void CreateScreenScrollbuttons() int gd_x1, gd_x2, gd_y1, gd_y2; int id = scrollbutton_info[i].gadget_id; - x = scrollbutton_info[i].x; - y = scrollbutton_info[i].y; - event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED; - x += SX; - y += SY; + x = mSX + scrollbutton_info[i].x + menu.scrollbar_xoffset; + y = mSY + scrollbutton_info[i].y; width = SC_SCROLLBUTTON_XSIZE; height = SC_SCROLLBUTTON_YSIZE; + if (id == SCREEN_CTRL_ID_SCROLL_DOWN) + y = mSY + (SC_SCROLL_VERTICAL_YPOS + + (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE); + gfx_unpressed = scrollbutton_info[i].gfx_unpressed; gfx_pressed = scrollbutton_info[i].gfx_pressed; gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap; @@ -2873,19 +2956,28 @@ static void CreateScreenScrollbars() #if !defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND) int gfx_unpressed, gfx_pressed; #endif + int x, y, width, height; int gd_x1, gd_x2, gd_y1, gd_y2; struct GadgetInfo *gi; int items_max, items_visible, item_position; unsigned long event_mask; - int num_page_entries = MAX_MENU_ENTRIES_ON_SCREEN; + int num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN; int id = scrollbar_info[i].gadget_id; + event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS; + + x = mSX + scrollbar_info[i].x + menu.scrollbar_xoffset; + y = mSY + scrollbar_info[i].y; + width = scrollbar_info[i].width; + height = scrollbar_info[i].height; + + if (id == SCREEN_CTRL_ID_SCROLL_VERTICAL) + height = (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE; + items_max = num_page_entries; items_visible = num_page_entries; item_position = 0; - event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS; - #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND) gd_bitmap_unpressed = *scrollbar_info[i].gfx_unpressed; gd_bitmap_pressed = *scrollbar_info[i].gfx_pressed; @@ -2907,10 +2999,10 @@ static void CreateScreenScrollbars() gi = CreateGadget(GDI_CUSTOM_ID, id, GDI_CUSTOM_TYPE_ID, i, GDI_INFO_TEXT, scrollbar_info[i].infotext, - GDI_X, scrollbar_info[i].x, - GDI_Y, scrollbar_info[i].y, - GDI_WIDTH, scrollbar_info[i].width, - GDI_HEIGHT, scrollbar_info[i].height, + GDI_X, x, + GDI_Y, y, + GDI_WIDTH, width, + GDI_HEIGHT, height, GDI_TYPE, scrollbar_info[i].type, GDI_SCROLLBAR_ITEMS_MAX, items_max, GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible, @@ -2932,6 +3024,8 @@ static void CreateScreenScrollbars() void CreateScreenGadgets() { + int last_game_status = game_status; /* save current game status */ + #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND) int i; @@ -2953,8 +3047,13 @@ void CreateScreenGadgets() } #endif + /* force LEVELS draw offset for scrollbar / scrollbutton gadgets */ + game_status = GAME_MODE_LEVELS; + CreateScreenScrollbuttons(); CreateScreenScrollbars(); + + game_status = last_game_status; /* restore current game status */ } void FreeScreenGadgets() @@ -2981,7 +3080,7 @@ void MapChooseTreeGadgets(TreeInfo *ti) int num_entries = numTreeInfoInGroup(ti); int i; - if (num_entries <= MAX_MENU_ENTRIES_ON_SCREEN) + if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN) return; for (i=0; i