📄 tree.c
字号:
case ONPLAY_START_PLAY: used = false; /* this will enable the wps */ break; } exit = true; break; }#ifdef BUTTON_ON case BUTTON_ON | BUTTON_REL: case BUTTON_ON | TREE_PREV | BUTTON_REL: case BUTTON_ON | TREE_NEXT | BUTTON_REL: exit = true; break;#endif } if ( used && !exit ) {#ifdef HAVE_LCD_BITMAP int xpos,ypos;#endif showdir(currdir, dirstart, dirfilter);#ifdef HAVE_LCD_BITMAP if (global_settings.invert_cursor) { xpos = lcd_getxmargin(); ypos = (CURSOR_Y + dircursor) * fh + lcd_getymargin(); lcd_invertrect(xpos, ypos, LCD_WIDTH-xpos, fh); } else#endif put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); lcd_update(); } } *ds = dirstart; *dc = dircursor; return used;}#endifstatic bool dirbrowse(char *root, int *dirfilter){ int numentries=0; char buf[MAX_PATH]; int i; int lasti=-1; int button; int tree_max_on_screen; bool reload_root = false; int lastfilter = *dirfilter; bool lastsortcase = global_settings.sort_case; int lastdircursor=-1; bool need_update = true; bool exit_func = false; bool update_all = false; /* set this to true when the whole file list has been refreshed on screen */#ifdef HAVE_LCD_BITMAP int fw, fh; lcd_setfont(FONT_UI); lcd_getstringsize("A", &fw, &fh); tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh;#else tree_max_on_screen = TREE_MAX_ON_SCREEN;#endif dircursor=0; dirstart=0; dirlevel=0; memcpy(currdir,root,sizeof(currdir)); if (*dirfilter < NUM_FILTER_MODES) start_resume(true); numentries = showdir(currdir, dirstart, dirfilter); if (numentries == -1) return false; /* currdir is not a directory */ if (*dirfilter > NUM_FILTER_MODES && numentries==0) { splash(HZ*2, true, str(LANG_NO_FILES)); return false; /* No files found for rockbox_browser() */ } update_all = true; put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); while(1) { struct entry* file = &dircache[dircursor+dirstart]; bool restore = false; button = button_get_w_tmo(HZ/5);#ifndef SIMULATOR if (boot_changed) { lcd_clear_display(); lcd_puts(0,0,str(LANG_BOOT_CHANGED)); lcd_puts(0,1,str(LANG_REBOOT_NOW));#ifdef HAVE_LCD_BITMAP lcd_puts(0,3,str(LANG_CONFIRM_WITH_PLAY_RECORDER)); lcd_puts(0,4,str(LANG_CANCEL_WITH_ANY_RECORDER)); lcd_update();#endif if (button_get(true) == BUTTON_PLAY) rolo_load("/" BOOTFILE); restore = true; boot_changed = false; }#endif switch ( button ) { case TREE_EXIT:#ifdef BUTTON_RC_STOP case BUTTON_RC_STOP:#endif#ifdef HAVE_RECORDER_KEYPAD case BUTTON_LEFT | BUTTON_REPEAT:#endif i=strlen(currdir); if (i>1) { while (currdir[i-1]!='/') i--; strcpy(buf,&currdir[i]); if (i==1) currdir[i]=0; else currdir[i-1]=0; dirlevel--; if ( dirlevel < MAX_DIR_LEVELS ) { dirstart = dirpos[dirlevel]; dircursor = cursorpos[dirlevel]; } else dirstart = dircursor = 0; if (dirstart == -1) strcpy(lastfile, buf); restore = true; } if (*dirfilter > NUM_FILTER_MODES) exit_func = true; break;#ifdef HAVE_RECORDER_KEYPAD case BUTTON_OFF: bookmark_autobookmark(); mpeg_stop(); status_set_playmode(STATUS_STOP); status_draw(false); restore = true; break; case BUTTON_OFF | BUTTON_REL:#else case BUTTON_STOP | BUTTON_REL:#endif settings_save(); break;#ifdef HAVE_RECORDER_KEYPAD case BUTTON_OFF | BUTTON_REPEAT:#else case BUTTON_STOP | BUTTON_REPEAT:#endif if (charger_inserted()) { charging_splash(); restore = true; } break; case TREE_ENTER: case TREE_ENTER | BUTTON_REPEAT:#ifdef BUTTON_RC_PLAY case BUTTON_RC_PLAY:#endif#ifdef HAVE_RECORDER_KEYPAD case BUTTON_PLAY: case BUTTON_PLAY | BUTTON_REPEAT:#endif if ( !numentries ) break; if (currdir[1]) snprintf(buf,sizeof(buf),"%s/%s",currdir, file->name); else snprintf(buf,sizeof(buf),"/%s",file->name); if (file->attr & ATTR_DIRECTORY) { memcpy(currdir,buf,sizeof(currdir)); if ( dirlevel < MAX_DIR_LEVELS ) { dirpos[dirlevel] = dirstart; cursorpos[dirlevel] = dircursor; } dirlevel++; dircursor=0; dirstart=0; } else { int seed = current_tick; bool play = false; int start_index=0; lcd_stop_scroll(); switch ( file->attr & TREE_ATTR_MASK ) { case TREE_ATTR_M3U: if (bookmark_autoload(buf)) { restore = true; break; } if (playlist_create(currdir, file->name) != -1) { if (global_settings.playlist_shuffle) playlist_shuffle(seed, -1); start_index = 0; playlist_start(start_index,0); play = true; } break; case TREE_ATTR_MPA: if (bookmark_autoload(currdir)) { restore = true; break; } if (playlist_create(currdir, NULL) != -1) { start_index = build_playlist(dircursor+dirstart); if (global_settings.playlist_shuffle) { start_index = playlist_shuffle(seed,start_index); /* when shuffling dir.: play all files even if the file selected by user is not the first one */ if (!global_settings.play_selected) start_index = 0; } playlist_start(start_index, 0); play = true; } break; /* wps config file */ case TREE_ATTR_WPS: wps_load(buf,true); set_file(buf, global_settings.wps_file, MAX_FILENAME); restore = true; break; case TREE_ATTR_CFG: if (!settings_load_config(buf)) break; lcd_clear_display(); lcd_puts(0,0,str(LANG_SETTINGS_LOADED1)); lcd_puts(0,1,str(LANG_SETTINGS_LOADED2));#ifdef HAVE_LCD_BITMAP lcd_update(); /* maybe we have a new font */ 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++; }#endif sleep(HZ/2); restore = true; break; case TREE_ATTR_BMARK: bookmark_load(buf, false); restore = true; reload_dir = true; break; case TREE_ATTR_TXT: plugin_load("/.rockbox/rocks/viewer.rock",buf); restore = true; break; case TREE_ATTR_LNG: if(!lang_load(buf)) { set_file(buf, global_settings.lang_file, MAX_FILENAME); splash(HZ, true, str(LANG_LANGUAGE_LOADED)); restore = true; } break;#ifdef HAVE_LCD_BITMAP /* chip-8 game */ case TREE_ATTR_CH8: plugin_load("/.rockbox/rocks/chip8.rock",buf); break; /* "movie" animation */ case TREE_ATTR_RVF: plugin_load("/.rockbox/rocks/video.rock",buf); break; case TREE_ATTR_FONT: font_load(buf); set_file(buf, global_settings.font_file, MAX_FILENAME); 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++; } restore = true; break;#endif#ifndef SIMULATOR /* firmware file */ case TREE_ATTR_MOD: rolo_load(buf); break; /* ucl flash file */ case TREE_ATTR_UCL: plugin_load("/.rockbox/rocks/rockbox_flash.rock",buf); break;#endif /* plugin file */ case TREE_ATTR_ROCK: if (plugin_load(buf,NULL) == PLUGIN_USB_CONNECTED) reload_root = true; else restore = true; break; } if ( play ) { if ( global_settings.resume ) { /* the resume_index must always be the index in the shuffled list in case shuffle is enabled */ global_settings.resume_index = start_index; global_settings.resume_offset = 0; settings_save(); } start_wps = true; } else if (*dirfilter > NUM_FILTER_MODES) exit_func = true; } restore = true; break; case TREE_PREV: case TREE_PREV | BUTTON_REPEAT:#ifdef BUTTON_RC_LEFT case BUTTON_RC_LEFT:#endif 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, dirfilter); update_all=true; put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); } else { if (numentries < tree_max_on_screen) { put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, false); 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, dirfilter);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -