From 5c7c1498d0f9560dda7fad6bda93d3c1d373c11f Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sun, 27 Mar 2022 14:54:40 +0200 Subject: [PATCH] added cursor key navigation to music info screens --- src/files.c | 12 ++++++++++++ src/main.h | 2 +- src/screens.c | 12 ++++++------ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/files.c b/src/files.c index a2efae2a..307b7889 100644 --- a/src/files.c +++ b/src/files.c @@ -13430,6 +13430,18 @@ void LoadMusicInfo(void) new = &(*new)->next; } } + + // add pointers to previous list nodes + + struct MusicFileInfo *node = music_file_info; + + while (node != NULL) + { + if (node->next) + node->next->prev = node; + + node = node->next; + } } static void add_helpanim_entry(int element, int action, int direction, diff --git a/src/main.h b/src/main.h index 3d6055a8..b4a57291 100644 --- a/src/main.h +++ b/src/main.h @@ -3715,7 +3715,7 @@ struct MusicFileInfo boolean is_sound; - struct MusicFileInfo *next; + struct MusicFileInfo *prev, *next; }; struct ElementActionInfo diff --git a/src/screens.c b/src/screens.c index 816f01ed..c3c87f24 100644 --- a/src/screens.c +++ b/src/screens.c @@ -279,7 +279,7 @@ static void DrawInfoScreen_HelpText(int, int, int, int); static void HandleInfoScreen_Main(int, int, int, int, int); static void HandleInfoScreen_TitleScreen(int); static void HandleInfoScreen_Elements(int); -static void HandleInfoScreen_Music(int); +static void HandleInfoScreen_Music(int, int, int); static void HandleInfoScreen_Credits(int, int, int); static void HandleInfoScreen_Program(int); static void HandleInfoScreen_Version(int); @@ -3199,12 +3199,12 @@ static void DrawInfoScreen_Music(void) LoadMusicInfo(); - HandleInfoScreen_Music(MB_MENU_INITIALIZE); + HandleInfoScreen_Music(0, 0, MB_MENU_INITIALIZE); FadeIn(REDRAW_FIELD); } -void HandleInfoScreen_Music(int button) +void HandleInfoScreen_Music(int dx, int dy, int button) { static struct MusicFileInfo *list = NULL; int font_title = MENU_INFO_FONT_TITLE; @@ -3250,14 +3250,14 @@ void HandleInfoScreen_Music(int button) return; } - else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE) + else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE || dx) { if (button != MB_MENU_INITIALIZE) { PlaySound(SND_MENU_ITEM_SELECTING); if (list != NULL) - list = list->next; + list = (dx < 0 ? list->prev : list->next); } if (list == NULL) @@ -4064,7 +4064,7 @@ void HandleInfoScreen(int mx, int my, int dx, int dy, int button) else if (info_mode == INFO_MODE_ELEMENTS) HandleInfoScreen_Elements(button); else if (info_mode == INFO_MODE_MUSIC) - HandleInfoScreen_Music(button); + HandleInfoScreen_Music(dx, dy, button); else if (info_mode == INFO_MODE_CREDITS) HandleInfoScreen_Credits(dx, dy, button); else if (info_mode == INFO_MODE_PROGRAM) -- 2.34.1