From 99ea957edc68bf087e037cd6678828ce479cccc1 Mon Sep 17 00:00:00 2001 From: Wintermute Date: Tue, 22 Oct 2013 22:23:36 +0200 Subject: [PATCH] =?utf8?q?Men=C3=BCcode=20aufger=C3=A4umt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- badge/jumpnrun/levels/levels.lst | 2 +- badge/ui/menu.c | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/badge/jumpnrun/levels/levels.lst b/badge/jumpnrun/levels/levels.lst index d31048a..68ea35a 100755 --- a/badge/jumpnrun/levels/levels.lst +++ b/badge/jumpnrun/levels/levels.lst @@ -7,7 +7,7 @@ kinder.de|sleazy.lvl b-uhse.de|lubilove.lvl sega.com|smb.lvl trollcon.de|23xentry.lvl -4chan.org|23hq.lvl +4chan.org|23xhq.lvl boeing.com|gnobbel.lvl pr0n.to|lubiXOXO.lvl lufthansa.de|slsky.lvl diff --git a/badge/ui/menu.c b/badge/ui/menu.c index 0627a10..b64e6d7 100644 --- a/badge/ui/menu.c +++ b/badge/ui/menu.c @@ -65,11 +65,21 @@ static void badge_menu_show(char const *const *menu, } size_t badge_menu(char const *const *menu, - size_t n, - size_t *first_visible, - size_t selected) + size_t n, + size_t *first_visible, + size_t selected) { for(;;) { + if(n <= MENU_ENTRIES_VISIBLE) { + *first_visible = 0; + } else if(selected + 1 == n) { + *first_visible = n - MENU_ENTRIES_VISIBLE; + } else if(selected <= *first_visible) { + *first_visible = selected == 0 ? 0 : selected - 1; + } else if(selected - *first_visible + 2 > MENU_ENTRIES_VISIBLE) { + *first_visible = selected - MENU_ENTRIES_VISIBLE + 2; + } + badge_menu_show(menu, n, *first_visible, selected); badge_event_t ev; @@ -86,14 +96,8 @@ size_t badge_menu(char const *const *menu, return selected; } else if((new_buttons & BADGE_EVENT_KEY_UP ) && selected != 0) { --selected; - if(*first_visible != 0 && selected <= *first_visible) { - *first_visible = selected - 1; - } } else if(new_buttons & BADGE_EVENT_KEY_DOWN && selected + 1 < n) { ++selected; - if(*first_visible + (MENU_ENTRIES_VISIBLE - 2 + (selected + 1 == n)) < selected) { - *first_visible = selected - (MENU_ENTRIES_VISIBLE - 2 + (selected + 1 == n)); - } } } } -- 2.20.1