Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: Re: .rockbox/ browsing, .rockbox/ playlists patch
From: George Styles (george_at_ripnet.co.uk)
Date: 2002-12-18


Cool... this is what I was after :) cant wait to try it...

Will let you know how I find it

thanks
George

----- Original Message -----
From: "Brian King" <brking_at_charter.net>
To: <rockbox_at_cool.haxx.se>
Sent: Wednesday, December 18, 2002 3:49 AM
Subject: .rockbox/ browsing, .rockbox/ playlists patch

> Here is an updated .rockbox/ browsing patch that adds a Playlists menu,
> which browses .rockbox/ and displays only .m3u files.
>
> -Brian
>
> --
> Some days it's just not worth chewing through the restraints...
>

----------------------------------------------------------------------------

----

> Index: main_menu.c > =================================================================== > RCS file: /cvsroot/rockbox/apps/main_menu.c,v > retrieving revision 1.71 > diff -u -r1.71 main_menu.c > --- main_menu.c 3 Dec 2002 22:41:48 -0000 1.71 > +++ main_menu.c 18 Dec 2002 03:44:43 -0000 > @@ -239,6 +239,16 @@ > return false; > } > > +bool firmware_menu(void) > +{ > + return rockbox_browse(SHOW_MOD); > +} > + > +bool playlist_menu(void) > +{ > + return rockbox_browse(SHOW_PLAYLIST_ONLY); > +} > + > bool main_menu(void) > { > int m; > @@ -246,6 +256,7 @@ > > /* main menu */ > struct menu_items items[] = { > + { str(LANG_PLAYLISTS), playlist_menu }, > { str(LANG_SOUND_SETTINGS), sound_menu }, > { str(LANG_GENERAL_SETTINGS), settings_menu }, > { str(LANG_SLEEP_TIMER), sleeptimer_screen }, > @@ -262,6 +273,7 @@ > #endif /* end USE_DEMOS */ > #endif > { str(LANG_INFO), show_info }, > + { str(LANG_FIRMWARE), firmware_menu }, > { str(LANG_VERSION), show_credits }, > #ifndef SIMULATOR > { str(LANG_DEBUG), debug_menu }, > Index: settings.h > =================================================================== > RCS file: /cvsroot/rockbox/apps/settings.h,v > retrieving revision 1.63 > diff -u -r1.63 settings.h > --- settings.h 12 Dec 2002 15:20:31 -0000 1.63 > +++ settings.h 18 Dec 2002 03:44:44 -0000 > @@ -186,7 +186,8 @@ > enum { REPEAT_OFF, REPEAT_ALL, REPEAT_ONE, NUM_REPEAT_MODES }; > > /* dir filter options */ > -enum { SHOW_ALL, SHOW_SUPPORTED, SHOW_MUSIC, SHOW_PLAYLIST, NUM_FILTER_MODES }; > +enum { SHOW_ALL, SHOW_SUPPORTED, SHOW_MUSIC, SHOW_PLAYLIST, NUM_FILTER_MODES, > +SHOW_WPS, SHOW_CFG, SHOW_LNG, SHOW_MOD, SHOW_PLAYLIST_ONLY}; > > #endif /* __SETTINGS_H__ */ > > Index: settings_menu.c > =================================================================== > RCS file: /cvsroot/rockbox/apps/settings_menu.c,v > retrieving revision 1.87 > diff -u -r1.87 settings_menu.c > --- settings_menu.c 12 Dec 2002 20:40:04 -0000 1.87 > +++ settings_menu.c 18 Dec 2002 03:44:45 -0000 > @@ -36,6 +36,7 @@ > #include "powermgmt.h" > #include "rtc.h" > #include "ata.h" > +#include "tree.h" > #include "screens.h" > #ifdef HAVE_LCD_BITMAP > #include "peakmeter.h" > @@ -397,6 +398,11 @@ > names, 15, set_poweroff_timeout); > } > > +static bool language_menu(void) > +{ > + return rockbox_browse(SHOW_LNG); > +} > + > static bool scroll_speed(void) > { > return set_int(str(LANG_SCROLL), "Hz", &global_settings.scroll_speed, > @@ -555,6 +561,11 @@ > return set_bool( str(LANG_FOLLOW), &global_settings.browse_current ); > } > > +static bool custom_wps_menu(void) > +{ > + return rockbox_browse(SHOW_WPS); > +} > + > static bool playback_settings_menu(void) > { > int m; > @@ -695,6 +706,7 @@ > { str(LANG_VOLUME_DISPLAY), volume_type }, > { str(LANG_BATTERY_DISPLAY), battery_type }, > #endif > + { str(LANG_LANGUAGE), language_menu }, > }; > > m=menu_init( items, sizeof items / sizeof(struct menu_items) ); > @@ -737,6 +749,7 @@ > > struct menu_items items[] = { > { str(LANG_PLAYBACK), playback_settings_menu }, > + { str(LANG_WHILE_PLAYING), custom_wps_menu }, > { str(LANG_FILE), fileview_settings_menu }, > { str(LANG_DISPLAY), display_settings_menu }, > { str(LANG_SYSTEM), system_settings_menu }, > Index: sound_menu.c > =================================================================== > RCS file: /cvsroot/rockbox/apps/sound_menu.c,v > retrieving revision 1.31 > diff -u -r1.31 sound_menu.c > --- sound_menu.c 10 Nov 2002 23:18:33 -0000 1.31 > +++ sound_menu.c 18 Dec 2002 03:44:46 -0000 > @@ -27,6 +27,7 @@ > #include "settings.h" > #include "status.h" > #include "screens.h" > +#include "tree.h" > #ifdef HAVE_LCD_BITMAP > #include "icons.h" > #endif > @@ -138,6 +139,11 @@ > return false; > } > > +static bool custom_snd(void) > +{ > + return rockbox_browse(SHOW_CFG); > +} > + > static bool volume(void) > { > return set_sound(str(LANG_VOLUME), &global_settings.volume, SOUND_VOLUME); > @@ -238,6 +244,7 @@ > int m; > bool result; > struct menu_items items[] = { > + { str(LANG_CUSTOM_SND), custom_snd }, > { str(LANG_VOLUME), volume }, > { str(LANG_BASS), bass }, > { str(LANG_TREBLE), treble }, > Index: tree.c > =================================================================== > RCS file: /cvsroot/rockbox/apps/tree.c,v > retrieving revision 1.148 > diff -u -r1.148 tree.c > --- tree.c 2 Dec 2002 04:46:19 -0000 1.148 > +++ tree.c 18 Dec 2002 03:44:50 -0000 > @@ -56,27 +56,59 @@ > > #define NAME_BUFFER_SIZE (AVERAGE_FILENAME_LENGTH * MAX_FILES_IN_DIR) > > -char name_buffer[NAME_BUFFER_SIZE]; > -int name_buffer_length; > +char name_buffer_save[NAME_BUFFER_SIZE]; > +int name_buffer_length_save; > + > +char name_buffer_rock[NAME_BUFFER_SIZE]; > +int name_buffer_length_rock; > + > +char *name_buffer = name_buffer_save; > +int *name_buffer_length = &name_buffer_length_save; > + > struct entry { > short attr; /* FAT attributes + file type flags */ > char *name; > }; > > -static struct entry dircache[MAX_FILES_IN_DIR]; > -static int dircursor; > -static int dirstart; > -static int dirlevel; > -static int filesindir; > -static int dirpos[MAX_DIR_LEVELS]; > -static int cursorpos[MAX_DIR_LEVELS]; > -static char lastdir[MAX_PATH]; > -static char lastfile[MAX_PATH]; > -static char currdir[MAX_PATH]; > +static struct entry dircache_save[MAX_FILES_IN_DIR]; > +static int dircursor_save; > +static int dirstart_save; > +static int dirlevel_save; > +static int filesindir_save; > +static int dirpos_save[MAX_DIR_LEVELS]; > +static int cursorpos_save[MAX_DIR_LEVELS]; > +static char lastdir_save[MAX_PATH]; > +static char lastfile_save[MAX_PATH]; > +static char currdir_save[MAX_PATH]; > + > +static struct entry dircache_rock[MAX_FILES_IN_DIR]; > +static int dircursor_rock; > +static int dirstart_rock; > +static int dirlevel_rock; > +static int filesindir_rock; > +static int dirpos_rock[MAX_DIR_LEVELS]; > +static int cursorpos_rock[MAX_DIR_LEVELS]; > +static char lastdir_rock[MAX_PATH]; > +static char lastfile_rock[MAX_PATH]; > +static char currdir_rock[MAX_PATH]; > +static int last_dirfilter_rock = SHOW_ALL; > + > +static struct entry *dircache = dircache_save; > +static int *dircursor = &dircursor_save; > +static int *dirstart = &dirstart_save; > +static int *dirlevel = &dirlevel_save; > +static int *filesindir = &filesindir_save; > +static int *dirpos = dirpos_save; > +static int *cursorpos = cursorpos_save; > +static char *lastdir = lastdir_save; > +static char *lastfile = lastfile_save; > +static char *currdir = currdir_save; > + > +static bool new_playlist = false; > > void browse_root(void) > { > - dirbrowse("/"); > + dirbrowse("/", global_settings.dirfilter); > } > > > @@ -84,7 +116,7 @@ > > /* pixel margins */ > #define MARGIN_X (global_settings.scrollbar && \ > - filesindir > tree_max_on_screen ? SCROLLBAR_WIDTH : 0) + \ > + *filesindir > tree_max_on_screen ? SCROLLBAR_WIDTH : 0) + \ > CURSOR_WIDTH + ICON_WIDTH > #define MARGIN_Y (global_settings.statusbar ? STATUSBAR_HEIGHT : 0) > > @@ -93,7 +125,7 @@ > #define LINE_Y (global_settings.statusbar ? 1 : 0) > > #define CURSOR_X (global_settings.scrollbar && \ > - filesindir > tree_max_on_screen ? 1 : 0) > + *filesindir > tree_max_on_screen ? 1 : 0) > #define CURSOR_Y 0 /* the cursor is not positioned in regard to > the margins, so this is the amount of lines > we add to the cursor Y position to position > @@ -152,7 +184,7 @@ > > playlist_clear(); > > - for(i = 0;i < filesindir;i++) > + for(i = 0;i < *filesindir;i++) > { > if(dircache[i].attr & TREE_ATTR_MPA) > { > @@ -184,7 +216,7 @@ > return ( e2->attr & ATTR_DIRECTORY ) - ( e1->attr & ATTR_DIRECTORY ); > } > > -static int showdir(char *path, int start) > +static int showdir(char *path, int start, int dirfilter) > { > int icon_type = 0; > int i; > @@ -203,12 +235,12 @@ > #endif > > /* new dir? cache it */ > - if (strncmp(path,lastdir,sizeof(lastdir))) { > + if (strncmp(path,lastdir,sizeof(lastdir_save))) { > DIR *dir = opendir(path); > if(!dir) > return -1; /* not a directory */ > > - name_buffer_length = 0; > + *name_buffer_length = 0; > dir_buffer_full = false; > > for ( i=0; i<MAX_FILES_IN_DIR; i++ ) { > @@ -237,7 +269,7 @@ > } > > /* filter out dotfiles and hidden files */ > - if (global_settings.dirfilter != SHOW_ALL && > + if (dirfilter != SHOW_ALL && > ((entry->d_name[0]=='.') || > (entry->attribute & ATTR_HIDDEN))) { > i--; > @@ -273,7 +305,7 @@ > } > > /* filter out all non-playlist files */ > - if ( global_settings.dirfilter == SHOW_PLAYLIST && > + if ( dirfilter == SHOW_PLAYLIST && > (!(dptr->attr & > (ATTR_DIRECTORY|TREE_ATTR_M3U))) ) { > i--; > @@ -281,7 +313,7 @@ > } > > /* filter out non-music files */ > - if ( global_settings.dirfilter == SHOW_MUSIC && > + if ( dirfilter == SHOW_MUSIC && > (!(dptr->attr & > (ATTR_DIRECTORY|TREE_ATTR_MPA|TREE_ATTR_M3U))) ) { > i--; > @@ -289,28 +321,63 @@ > } > > /* filter out non-supported files */ > - if ( global_settings.dirfilter == SHOW_SUPPORTED && > + if ( dirfilter == SHOW_SUPPORTED && > (!(dptr->attr & TREE_ATTR_MASK)) ) { > i--; > continue; > } > > - if (len > NAME_BUFFER_SIZE - name_buffer_length - 1) { > + /* filter out non-wps files */ > + if ( dirfilter == SHOW_WPS && > + ((dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_WPS) ) { > + i--; > + continue; > + } > + > + /* filter out non-cfg files */ > + if ( dirfilter == SHOW_CFG && > + ((dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_CFG) ) { > + i--; > + continue; > + } > + > + /* filter out non-lng files */ > + if ( dirfilter == SHOW_LNG && > + ((dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_LNG) ) { > + i--; > + continue; > + } > + > + /* filter out non-mod files */ > + if ( dirfilter == SHOW_MOD && > + ((dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_MOD) ) { > + i--; > + continue; > + } > + > + /* filter out non-mod files */ > + if ( dirfilter == SHOW_PLAYLIST_ONLY && > + ((dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_M3U) ) { > + i--; > + continue; > + } > + > + if (len > NAME_BUFFER_SIZE - (*name_buffer_length) - 1) { > /* Tell the world that we ran out of buffer space */ > dir_buffer_full = true; > break; > } > - dptr->name = &name_buffer[name_buffer_length]; > + dptr->name = &name_buffer[*name_buffer_length]; > strcpy(dptr->name,entry->d_name); > - name_buffer_length += len + 1; > + (*name_buffer_length) += len + 1; > } > - filesindir = i; > + *filesindir = i; > closedir(dir); > - strncpy(lastdir,path,sizeof(lastdir)); > - lastdir[sizeof(lastdir)-1] = 0; > - qsort(dircache,filesindir,sizeof(struct entry),compare); > + strncpy(lastdir,path,sizeof(lastdir_save)); > + lastdir[sizeof(lastdir_save)-1] = 0; > + qsort(dircache,*filesindir,sizeof(struct entry),compare); > > - if ( dir_buffer_full || filesindir == MAX_FILES_IN_DIR ) { > + if ( dir_buffer_full || *filesindir == MAX_FILES_IN_DIR ) { > #ifdef HAVE_LCD_CHARCELLS > lcd_double_height(false); > #endif > @@ -330,7 +397,7 @@ > /* use lastfile to determine start (default=0) */ > start = 0; > > - for (i=0; i<filesindir; i++) > + for (i=0; i<*filesindir; i++) > { > if (!strcasecmp(dircache[i].name, lastfile)) > { > @@ -339,7 +406,7 @@ > } > } > > - diff_files = filesindir - start; > + diff_files = *filesindir - start; > if (diff_files < tree_max_on_screen) > { > int oldstart = start; > @@ -348,10 +415,10 @@ > if (start < 0) > start = 0; > > - dircursor = oldstart - start; > + *dircursor = oldstart - start; > } > > - dirstart = start; > + *dirstart = start; > } > > lcd_stop_scroll(); > @@ -367,7 +434,7 @@ > for ( i=start; i < start+tree_max_on_screen; i++ ) { > int len; > > - if ( i >= filesindir ) > + if ( i >= *filesindir ) > break; > > len = strlen(dircache[i].name); > @@ -430,7 +497,7 @@ > } > > /* if music filter is on, cut off the extension */ > - if (global_settings.dirfilter == SHOW_MUSIC && > + if (dirfilter == SHOW_MUSIC && > (dircache[i].attr & (TREE_ATTR_M3U|TREE_ATTR_MPA))) > { > char temp = dircache[i].name[len-4]; > @@ -443,13 +510,13 @@ > } > > #ifdef HAVE_LCD_BITMAP > - if (global_settings.scrollbar && filesindir > tree_max_on_screen) > + if (global_settings.scrollbar && *filesindir > tree_max_on_screen) > scrollbar(SCROLLBAR_X, SCROLLBAR_Y, SCROLLBAR_WIDTH - 1, > - LCD_HEIGHT - SCROLLBAR_Y, filesindir, start, > + LCD_HEIGHT - SCROLLBAR_Y, *filesindir, start, > start + tree_max_on_screen, VERTICAL); > #endif > status_draw(); > - return filesindir; > + return *filesindir; > } > > bool ask_resume(void) > @@ -544,7 +611,7 @@ > if (!ask_resume()) > return; > > - if (showdir(global_settings.resume_file, 0) < 0 ) > + if (showdir(global_settings.resume_file, 0, global_settings.dirfilter) < 0 ) > return; > > lastdir[0] = '\0'; > @@ -587,30 +654,30 @@ > > strcpy(lastfile, name); > > - dircursor = 0; > - dirstart = -1; > + *dircursor = 0; > + *dirstart = -1; > > - if (strncmp(currdir,lastdir,sizeof(lastdir))) > + if (strncmp(currdir,lastdir,sizeof(lastdir_save))) > { > - dirlevel = 0; > - dirpos[dirlevel] = -1; > - cursorpos[dirlevel] = 0; > + *dirlevel = 0; > + dirpos[*dirlevel] = -1; > + cursorpos[*dirlevel] = 0; > > /* use '/' to calculate dirlevel */ > for (i=1; i<strlen(path)+1; i++) > { > if (path[i] == '/') > { > - dirlevel++; > - dirpos[dirlevel] = -1; > - cursorpos[dirlevel] = 0; > + (*dirlevel)++; > + dirpos[*dirlevel] = -1; > + cursorpos[*dirlevel] = 0; > } > } > } > } > > #ifdef HAVE_RECORDER_KEYPAD > -bool pageupdown(int* ds, int* dc, int numentries, int tree_max_on_screen ) > +bool pageupdown(int* ds, int* dc, int numentries, int tree_max_on_screen, int dirfilter ) > { > bool exit = false; > bool used = false; > @@ -658,7 +725,7 @@ > break; > } > if ( used ) { > - showdir(currdir, dirstart); > + showdir(currdir, dirstart, dirfilter); > put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); > lcd_update(); > } > @@ -690,7 +757,7 @@ > settings_save(); > } > > -bool dirbrowse(char *root) > +bool dirbrowse(char *root, int dirfilter) > { > int numentries=0; > char buf[MAX_PATH]; > @@ -699,6 +766,7 @@ > int button; > int tree_max_on_screen; > bool reload_root = false; > + bool play = false; > int lastfilter = global_settings.dirfilter; > bool lastsortcase = global_settings.sort_case; > #ifdef HAVE_LCD_BITMAP > @@ -709,22 +777,23 @@ > tree_max_on_screen = TREE_MAX_ON_SCREEN; > #endif > > - dircursor=0; > - dirstart=0; > - dirlevel=0; > + *dircursor=0; > + *dirstart=0; > + *dirlevel=0; > > - memcpy(currdir,root,sizeof(currdir)); > + memcpy(currdir,root,sizeof(currdir_save)); > > - start_resume(); > + if (dirfilter < NUM_FILTER_MODES) > + start_resume(); > > - numentries = showdir(currdir, dirstart); > + numentries = showdir(currdir, *dirstart, dirfilter); > if (numentries == -1) > return -1; /* currdir is not a directory */ > > - put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); > + put_cursorxy(CURSOR_X, CURSOR_Y + *dircursor, true); > > while(1) { > - struct entry* file = &dircache[dircursor+dirstart]; > + struct entry* file = &dircache[*dircursor+*dirstart]; > > bool restore = false; > bool need_update = false; > @@ -743,15 +812,15 @@ > else > currdir[i-1]=0; > > - dirlevel--; > - if ( dirlevel < MAX_DIR_LEVELS ) { > - dirstart = dirpos[dirlevel]; > - dircursor = cursorpos[dirlevel]; > + (*dirlevel)--; > + if ( *dirlevel < MAX_DIR_LEVELS ) { > + *dirstart = dirpos[*dirlevel]; > + *dircursor = cursorpos[*dirlevel]; > } > else > - dirstart = dircursor = 0; > + *dirstart = *dircursor = 0; > > - if (dirstart == -1) > + if (*dirstart == -1) > strcpy(lastfile, buf); > > restore = true; > @@ -790,17 +859,17 @@ > } > > if (file->attr & ATTR_DIRECTORY) { > - memcpy(currdir,buf,sizeof(currdir)); > - if ( dirlevel < MAX_DIR_LEVELS ) { > - dirpos[dirlevel] = dirstart; > - cursorpos[dirlevel] = dircursor; > + memcpy(currdir,buf,sizeof(currdir_save)); > + if ( *dirlevel < MAX_DIR_LEVELS ) { > + dirpos[*dirlevel] = *dirstart; > + cursorpos[*dirlevel] = *dircursor; > } > - dirlevel++; > - dircursor=0; > - dirstart=0; > + (*dirlevel)++; > + *dircursor=0; > + *dirstart=0; > } else { > int seed = current_tick; > - bool play = false; > + play = false; > int start_index=0; > > lcd_stop_scroll(); > @@ -820,7 +889,7 @@ > if ( global_settings.resume ) > strncpy(global_settings.resume_file, > currdir, MAX_PATH); > - start_index = build_playlist(dircursor+dirstart); > + start_index = build_playlist(*dircursor+*dirstart); > > /* it is important that we get back the index in > the (shuffled) list and stor that */ > @@ -893,9 +962,9 @@ > lcd_getstringsize("A", &fw, &fh); > tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh; > /* make sure cursor is on screen */ > - while ( dircursor > tree_max_on_screen ) { > - dircursor--; > - dirstart++; > + while ( *dircursor > tree_max_on_screen ) { > + (*dircursor)--; > + (*dirstart)++; > } > restore = true; > break; > @@ -926,7 +995,10 @@ > status_set_playmode(STATUS_PLAY); > status_draw(); > lcd_stop_scroll(); > - if ( wps_show() == SYS_USB_CONNECTED ) { > + > + if (dirfilter > NUM_FILTER_MODES || > + wps_show() == SYS_USB_CONNECTED) > + { > reload_root = true; > global_settings.resume_index = -1; > } > @@ -941,30 +1013,30 @@ > case TREE_PREV: > case TREE_PREV | BUTTON_REPEAT: > case BUTTON_VOL_UP: > - if(filesindir) { > - if(dircursor) { > - put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, false); > - dircursor--; > - put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); > + if(*filesindir) { > + if(*dircursor) { > + put_cursorxy(CURSOR_X, CURSOR_Y + *dircursor, false); > + (*dircursor)--; > + put_cursorxy(CURSOR_X, CURSOR_Y + *dircursor, true); > } > else { > - if (dirstart) { > - dirstart--; > - numentries = showdir(currdir, dirstart); > - put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); > + if (*dirstart) { > + (*dirstart)--; > + numentries = showdir(currdir, *dirstart, dirfilter); > + put_cursorxy(CURSOR_X, CURSOR_Y + *dircursor, true); > } > else { > if (numentries < tree_max_on_screen) { > - put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, > + put_cursorxy(CURSOR_X, CURSOR_Y + *dircursor, > false); > - dircursor = numentries - 1; > - put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, > + *dircursor = numentries - 1; > + put_cursorxy(CURSOR_X, CURSOR_Y + *dircursor, > true); > } > else { > - dirstart = numentries - tree_max_on_screen; > - dircursor = tree_max_on_screen - 1; > - numentries = showdir(currdir, dirstart); > + *dirstart = numentries - tree_max_on_screen; > + *dircursor = tree_max_on_screen - 1; > + numentries = showdir(currdir, *dirstart, dirfilter); > put_cursorxy(CURSOR_X, CURSOR_Y + > tree_max_on_screen - 1, true); > } > @@ -977,32 +1049,32 @@ > case TREE_NEXT: > case TREE_NEXT | BUTTON_REPEAT: > case BUTTON_VOL_DOWN: > - if(filesindir) > + if(*filesindir) > { > - if (dircursor + dirstart + 1 < numentries ) { > - if(dircursor+1 < tree_max_on_screen) { > - put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, > + if (*dircursor + *dirstart + 1 < numentries ) { > + if(*dircursor+1 < tree_max_on_screen) { > + put_cursorxy(CURSOR_X, CURSOR_Y + *dircursor, > false); > - dircursor++; > - put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); > + (*dircursor)++; > + put_cursorxy(CURSOR_X, CURSOR_Y + *dircursor, true); > } > else { > - dirstart++; > - numentries = showdir(currdir, dirstart); > - put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); > + (*dirstart)++; > + numentries = showdir(currdir, *dirstart, dirfilter); > + put_cursorxy(CURSOR_X, CURSOR_Y + *dircursor, true); > } > } > else { > if(numentries < tree_max_on_screen) { > - put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, > + put_cursorxy(CURSOR_X, CURSOR_Y + *dircursor, > false); > - dirstart = dircursor = 0; > - put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); > + *dirstart = *dircursor = 0; > + put_cursorxy(CURSOR_X, CURSOR_Y + *dircursor, true); > } > else { > - dirstart = dircursor = 0; > - numentries = showdir(currdir, dirstart); > - put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); > + *dirstart = *dircursor = 0; > + numentries = showdir(currdir, *dirstart, dirfilter); > + put_cursorxy(CURSOR_X, CURSOR_Y + *dircursor, true); > } > } > need_update = true; > @@ -1014,11 +1086,25 @@ > if (main_menu()) > reload_root = true; > restore = true; > + > + if (new_playlist && > + mpeg_status() & MPEG_STATUS_PLAY) > + { > + new_playlist = false; > + lcd_stop_scroll(); > + if (global_settings.browse_current) > + reload_root = false; > + if (wps_show() == SYS_USB_CONNECTED) > + reload_root = true; > +#ifdef HAVE_LCD_BITMAP > + tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh; > +#endif > + } > break; > > case BUTTON_ON: > #ifdef HAVE_RECORDER_KEYPAD > - if (pageupdown(&dirstart, &dircursor, numentries, > + if (pageupdown(dirstart, dircursor, numentries, > tree_max_on_screen)) > { > /* start scroll */ > @@ -1071,7 +1157,13 @@ > > if ( button ) > ata_spin(); > - > + > + if (play && dirfilter > NUM_FILTER_MODES) > + { > + new_playlist = true; > + return true; > + } > + > /* do we need to rescan dir? */ > if (reload_root || > lastfilter != global_settings.dirfilter || > @@ -1079,54 +1171,58 @@ > { > if ( reload_root ) { > strcpy(currdir, "/"); > - dirlevel = 0; > + *dirlevel = 0; > reload_root = false; > } > - dircursor = 0; > - dirstart = 0; > + *dircursor = 0; > + *dirstart = 0; > lastdir[0] = 0; > lastfilter = global_settings.dirfilter; > lastsortcase = global_settings.sort_case; > restore = true; > + dirfilter = global_settings.dirfilter; > } > > if ( restore ) { > + if (dirfilter > NUM_FILTER_MODES){ > + break; > + } > /* restore display */ > /* We need to adjust if the number of lines on screen have > changed because of a status bar change */ > - if(CURSOR_Y+LINE_Y+dircursor>tree_max_on_screen) { > - dirstart++; > - dircursor--; > + if(CURSOR_Y+LINE_Y+*dircursor>tree_max_on_screen) { > + (*dirstart)++; > + (*dircursor)--; > } > #ifdef HAVE_LCD_BITMAP > /* the sub-screen might've ruined the margins */ > lcd_setmargins(MARGIN_X,MARGIN_Y); /* leave room for cursor and > icon */ > #endif > - numentries = showdir(currdir, dirstart); > - put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); > + numentries = showdir(currdir, *dirstart, dirfilter); > + put_cursorxy(CURSOR_X, CURSOR_Y + *dircursor, true); > > need_update = true; > } > > if ( numentries ) { > - i = dirstart+dircursor; > + i = *dirstart+*dircursor; > > /* if MP3 filter is on, cut off the extension */ > if(lasti!=i || restore) { > lasti=i; > lcd_stop_scroll(); > - if (global_settings.dirfilter == SHOW_MUSIC && > + if (dirfilter == SHOW_MUSIC && > (dircache[i].attr & (TREE_ATTR_M3U|TREE_ATTR_MPA))) > { > int len = strlen(dircache[i].name); > char temp = dircache[i].name[len-4]; > dircache[i].name[len-4] = 0; > - lcd_puts_scroll(LINE_X, dircursor, dircache[i].name); > + lcd_puts_scroll(LINE_X, *dircursor, dircache[i].name); > dircache[i].name[len-4] = temp; > } > else > - lcd_puts_scroll(LINE_X, dircursor, dircache[i].name); > + lcd_puts_scroll(LINE_X, *dircursor, dircache[i].name); > > need_update = true; > } > @@ -1140,6 +1236,52 @@ > } > > return false; > +} > + > +bool rockbox_browse(int dirfilter) > +{ > + bool rc; > + > + dircache = dircache_rock; > + dircursor = &dircursor_rock; > + dirstart = &dirstart_rock; > + dirlevel = &dirlevel_rock; > + filesindir = &filesindir_rock; > + dirpos = dirpos_rock; > + cursorpos = cursorpos_rock; > + lastdir = lastdir_rock; > + lastfile = lastfile_rock; > + currdir = currdir_rock; > + name_buffer = name_buffer_rock; > + name_buffer_length = &name_buffer_length_rock; > + > + if (last_dirfilter_rock != dirfilter) > + { > + strcpy(currdir, "/"); > + *dirlevel = 0; > + *dircursor = 0; > + *dirstart = 0; > + lastdir[0] = 0; > + } > + > + last_dirfilter_rock = dirfilter; > + > + rc = dirbrowse(ROCKBOX_DIR, dirfilter); > + > + dircache = dircache_save; > + dircursor = &dircursor_save; > + dirstart = &dirstart_save; > + dirlevel = &dirlevel_save; > + filesindir = &filesindir_save; > + dirpos = dirpos_save; > + cursorpos = cursorpos_save; > + lastdir = lastdir_save; > + lastfile = lastfile_save; > + currdir = currdir_save; > + name_buffer = name_buffer_save; > + name_buffer_length = &name_buffer_length_save; > + > + return rc; > } > > /* ----------------------------------------------------------------- > Index: tree.h > =================================================================== > RCS file: /cvsroot/rockbox/apps/tree.h,v > retrieving revision 1.2 > diff -u -r1.2 tree.h > --- tree.h 9 Sep 2002 14:25:39 -0000 1.2 > +++ tree.h 18 Dec 2002 03:44:50 -0000 > @@ -23,6 +23,7 @@ > > void browse_root(void); > void set_current_file(char *path); > -bool dirbrowse(char *root); > +bool dirbrowse(char *root, int dirfilter); > +bool rockbox_browse(int dirfilter); > > #endif > Index: lang/english.lang > =================================================================== > RCS file: /cvsroot/rockbox/apps/lang/english.lang,v > retrieving revision 1.40 > diff -u -r1.40 english.lang > --- lang/english.lang 12 Dec 2002 16:56:19 -0000 1.40 > +++ lang/english.lang 18 Dec 2002 03:44:50 -0000 > @@ -11,6 +11,11 @@ > # If you re-order things or remove entries, you must bump the binary language > # file version number in both the 'binlang' tool and the language loader code. > # > +id: LANG_PLAYLISTS > +desc: in the main menu > +eng: "Playlists" > +new: > + > id: LANG_SOUND_SETTINGS > desc: in the main menu > eng: "Sound Settings" > @@ -36,6 +41,11 @@ > eng: "Info" > new: > > +id: LANG_FIRMWARE > +desc: in the main menu > +eng: "Firmware" > +new: > + > id: LANG_VERSION > desc: in the main menu > eng: "Version" > @@ -186,6 +196,11 @@ > eng: "" > new: > > +id: LANG_LANGUAGE > +desc: in settings_menu > +eng: "Language" > +new: > + > id: LANG_CONTRAST > desc: in settings_menu > eng: "Contrast" > @@ -330,6 +345,11 @@ > eng: "Reset settings" > new: > > +id: LANG_WHILE_PLAYING > +desc: in settings_menu() > +eng: "While Playing" > +new: > + > id: LANG_PLAYBACK > desc: in settings_menu() > eng: "Playback" > @@ -350,6 +370,11 @@ > eng: "System" > new: > > +id: LANG_CUSTOM_SND > +desc: in sound_settings > +eng: "Custom" > +new: > + > id: LANG_VOLUME > desc: in sound_settings > eng: "Volume" > @@ -1200,4 +1225,4 @@ > id: LANG_SCROLL_SPEED > desc: in display_settings_menu() > eng: "Scroll Speed" > -new: > \ No newline at end of file > +new: >



Page was last modified "Jan 10 2012" The Rockbox Crew
aaa