forked from len0rd/rockbox
Added persistence of last .wps, .fnt and .lng file played in /.rockbox
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2535 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
b9d6830edd
commit
dea31222b8
7 changed files with 75 additions and 16 deletions
|
|
@ -47,6 +47,7 @@
|
||||||
#include "sprintf.h"
|
#include "sprintf.h"
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
#include "language.h"
|
#include "language.h"
|
||||||
|
#include "wps-display.h"
|
||||||
|
|
||||||
char appsversion[]=APPSVERSION;
|
char appsversion[]=APPSVERSION;
|
||||||
|
|
||||||
|
|
@ -68,6 +69,7 @@ void init(void)
|
||||||
show_logo();
|
show_logo();
|
||||||
settings_reset();
|
settings_reset();
|
||||||
settings_load();
|
settings_load();
|
||||||
|
wps_load(ROCKBOX_DIR "/default.wps", false);
|
||||||
font_load(ROCKBOX_DIR "/default.fnt");
|
font_load(ROCKBOX_DIR "/default.fnt");
|
||||||
lang_load(ROCKBOX_DIR "/default.lng");
|
lang_load(ROCKBOX_DIR "/default.lng");
|
||||||
sleep(HZ/2);
|
sleep(HZ/2);
|
||||||
|
|
@ -147,6 +149,7 @@ void init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
settings_load();
|
settings_load();
|
||||||
|
wps_load(ROCKBOX_DIR "/default.wps", false);
|
||||||
font_load(ROCKBOX_DIR "/default.fnt");
|
font_load(ROCKBOX_DIR "/default.fnt");
|
||||||
lang_load(ROCKBOX_DIR "/default.lng");
|
lang_load(ROCKBOX_DIR "/default.lng");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,9 @@
|
||||||
#include "icons.h"
|
#include "icons.h"
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "lang.h"
|
#include "lang.h"
|
||||||
|
#include "language.h"
|
||||||
|
#include "wps-display.h"
|
||||||
|
|
||||||
struct user_settings global_settings;
|
struct user_settings global_settings;
|
||||||
char rockboxdir[] = ROCKBOX_DIR; /* config/font/data file directory */
|
char rockboxdir[] = ROCKBOX_DIR; /* config/font/data file directory */
|
||||||
|
|
@ -112,6 +113,9 @@ modified unless the header & checksum test fails.
|
||||||
|
|
||||||
Rest of config block, only saved to disk:
|
Rest of config block, only saved to disk:
|
||||||
|
|
||||||
|
0xB8 (char[20]) WPS file
|
||||||
|
0xCC (char[20]) Lang file
|
||||||
|
0xE0 (char[20]) Font file
|
||||||
0xF4 (int) Playlist first index
|
0xF4 (int) Playlist first index
|
||||||
0xF8 (int) Playlist shuffle seed
|
0xF8 (int) Playlist shuffle seed
|
||||||
0xFC (char[260]) Resume playlist (path/to/dir or path/to/playlist.m3u)
|
0xFC (char[260]) Resume playlist (path/to/dir or path/to/playlist.m3u)
|
||||||
|
|
@ -313,6 +317,9 @@ int settings_save( void )
|
||||||
|
|
||||||
memcpy(&config_block[0x24], &global_settings.total_uptime, 4);
|
memcpy(&config_block[0x24], &global_settings.total_uptime, 4);
|
||||||
|
|
||||||
|
strncpy(&config_block[0xb8], global_settings.wps_file, MAX_FILENAME);
|
||||||
|
strncpy(&config_block[0xcc], global_settings.lang_file, MAX_FILENAME);
|
||||||
|
strncpy(&config_block[0xe0], global_settings.font_file, MAX_FILENAME);
|
||||||
memcpy(&config_block[0xF4], &global_settings.resume_first_index, 4);
|
memcpy(&config_block[0xF4], &global_settings.resume_first_index, 4);
|
||||||
memcpy(&config_block[0xF8], &global_settings.resume_seed, 4);
|
memcpy(&config_block[0xF8], &global_settings.resume_seed, 4);
|
||||||
|
|
||||||
|
|
@ -345,6 +352,8 @@ int settings_save( void )
|
||||||
|
|
||||||
void settings_apply(void)
|
void settings_apply(void)
|
||||||
{
|
{
|
||||||
|
char buf[64];
|
||||||
|
|
||||||
mpeg_sound_set(SOUND_BASS, global_settings.bass);
|
mpeg_sound_set(SOUND_BASS, global_settings.bass);
|
||||||
mpeg_sound_set(SOUND_TREBLE, global_settings.treble);
|
mpeg_sound_set(SOUND_TREBLE, global_settings.treble);
|
||||||
mpeg_sound_set(SOUND_BALANCE, global_settings.balance);
|
mpeg_sound_set(SOUND_BALANCE, global_settings.balance);
|
||||||
|
|
@ -367,6 +376,24 @@ void settings_apply(void)
|
||||||
#ifdef HAVE_CHARGE_CTRL
|
#ifdef HAVE_CHARGE_CTRL
|
||||||
charge_restart_level = global_settings.discharge ? CHARGE_RESTART_LO : CHARGE_RESTART_HI;
|
charge_restart_level = global_settings.discharge ? CHARGE_RESTART_LO : CHARGE_RESTART_HI;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if ( global_settings.wps_file[0] ) {
|
||||||
|
snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.wps",
|
||||||
|
global_settings.wps_file);
|
||||||
|
wps_load(buf, false);
|
||||||
|
}
|
||||||
|
#ifdef HAVE_LCD_BITMAP
|
||||||
|
if ( global_settings.font_file[0] ) {
|
||||||
|
snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.fnt",
|
||||||
|
global_settings.font_file);
|
||||||
|
font_load(buf);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if ( global_settings.lang_file[0] ) {
|
||||||
|
snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.lng",
|
||||||
|
global_settings.lang_file);
|
||||||
|
lang_load(buf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -473,6 +500,9 @@ void settings_load(void)
|
||||||
memcpy(&global_settings.resume_first_index, &config_block[0xF4], 4);
|
memcpy(&global_settings.resume_first_index, &config_block[0xF4], 4);
|
||||||
memcpy(&global_settings.resume_seed, &config_block[0xF8], 4);
|
memcpy(&global_settings.resume_seed, &config_block[0xF8], 4);
|
||||||
|
|
||||||
|
strncpy(global_settings.wps_file, &config_block[0xb8], MAX_FILENAME);
|
||||||
|
strncpy(global_settings.lang_file, &config_block[0xcc], MAX_FILENAME);
|
||||||
|
strncpy(global_settings.font_file, &config_block[0xe0], MAX_FILENAME);
|
||||||
strncpy(global_settings.resume_file, &config_block[0xFC], MAX_PATH);
|
strncpy(global_settings.resume_file, &config_block[0xFC], MAX_PATH);
|
||||||
global_settings.resume_file[MAX_PATH]=0;
|
global_settings.resume_file[MAX_PATH]=0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@
|
||||||
|
|
||||||
#define ROCKBOX_DIR "/.rockbox"
|
#define ROCKBOX_DIR "/.rockbox"
|
||||||
|
|
||||||
|
#define MAX_FILENAME 20
|
||||||
|
|
||||||
/* data structures */
|
/* data structures */
|
||||||
|
|
||||||
#define RESUME_OFF 0
|
#define RESUME_OFF 0
|
||||||
|
|
@ -75,6 +77,9 @@ struct user_settings
|
||||||
int resume_seed; /* random seed for playlist shuffle */
|
int resume_seed; /* random seed for playlist shuffle */
|
||||||
int resume_first_index; /* first index of playlist */
|
int resume_first_index; /* first index of playlist */
|
||||||
unsigned char resume_file[MAX_PATH+1]; /* playlist name (or dir) */
|
unsigned char resume_file[MAX_PATH+1]; /* playlist name (or dir) */
|
||||||
|
unsigned char font_file[MAX_FILENAME+1]; /* last font */
|
||||||
|
unsigned char wps_file[MAX_FILENAME+1]; /* last wps */
|
||||||
|
unsigned char lang_file[MAX_FILENAME+1]; /* last language */
|
||||||
|
|
||||||
/* misc options */
|
/* misc options */
|
||||||
|
|
||||||
|
|
|
||||||
32
apps/tree.c
32
apps/tree.c
|
|
@ -658,6 +658,26 @@ bool pageupdown(int* ds, int* dc, int numentries, int tree_max_on_screen )
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void storefile(char* filename, char* setting, int maxlen)
|
||||||
|
{
|
||||||
|
int len = strlen(filename);
|
||||||
|
int extlen = 0;
|
||||||
|
char* ptr = filename + len;
|
||||||
|
|
||||||
|
while (*ptr != '.') {
|
||||||
|
extlen++;
|
||||||
|
ptr--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(ROCKBOX_DIR, currdir) || (len > maxlen-extlen))
|
||||||
|
return;
|
||||||
|
|
||||||
|
strncpy(setting, filename, len-extlen);
|
||||||
|
setting[len-extlen]=0;
|
||||||
|
|
||||||
|
settings_save();
|
||||||
|
}
|
||||||
|
|
||||||
bool dirbrowse(char *root)
|
bool dirbrowse(char *root)
|
||||||
{
|
{
|
||||||
int numentries=0;
|
int numentries=0;
|
||||||
|
|
@ -771,6 +791,7 @@ bool dirbrowse(char *root)
|
||||||
int seed = current_tick;
|
int seed = current_tick;
|
||||||
bool play = false;
|
bool play = false;
|
||||||
int start_index=0;
|
int start_index=0;
|
||||||
|
|
||||||
lcd_stop_scroll();
|
lcd_stop_scroll();
|
||||||
switch ( file->attr & TREE_ATTR_MASK ) {
|
switch ( file->attr & TREE_ATTR_MASK ) {
|
||||||
case TREE_ATTR_M3U:
|
case TREE_ATTR_M3U:
|
||||||
|
|
@ -802,7 +823,9 @@ bool dirbrowse(char *root)
|
||||||
case TREE_ATTR_WPS:
|
case TREE_ATTR_WPS:
|
||||||
snprintf(buf, sizeof buf, "%s/%s",
|
snprintf(buf, sizeof buf, "%s/%s",
|
||||||
currdir, file->name);
|
currdir, file->name);
|
||||||
wps_load_custom(buf);
|
wps_load(buf,true);
|
||||||
|
storefile(file->name, global_settings.wps_file,
|
||||||
|
MAX_FILENAME);
|
||||||
restore = true;
|
restore = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -824,6 +847,10 @@ bool dirbrowse(char *root)
|
||||||
snprintf(buf, sizeof buf, "%s/%s",
|
snprintf(buf, sizeof buf, "%s/%s",
|
||||||
currdir, file->name);
|
currdir, file->name);
|
||||||
if(!lang_load(buf)) {
|
if(!lang_load(buf)) {
|
||||||
|
storefile(file->name,
|
||||||
|
global_settings.lang_file,
|
||||||
|
MAX_FILENAME);
|
||||||
|
|
||||||
lcd_clear_display();
|
lcd_clear_display();
|
||||||
#ifdef HAVE_LCD_CHARCELLS
|
#ifdef HAVE_LCD_CHARCELLS
|
||||||
lcd_puts(0, 0, str(LANG_LANGUAGE_LOADED));
|
lcd_puts(0, 0, str(LANG_LANGUAGE_LOADED));
|
||||||
|
|
@ -849,6 +876,9 @@ bool dirbrowse(char *root)
|
||||||
snprintf(buf, sizeof buf, "%s/%s",
|
snprintf(buf, sizeof buf, "%s/%s",
|
||||||
currdir, file->name);
|
currdir, file->name);
|
||||||
font_load(buf);
|
font_load(buf);
|
||||||
|
storefile(file->name, global_settings.font_file,
|
||||||
|
MAX_FILENAME);
|
||||||
|
|
||||||
lcd_getstringsize("A", &fw, &fh);
|
lcd_getstringsize("A", &fw, &fh);
|
||||||
tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh;
|
tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh;
|
||||||
/* make sure cursor is on screen */
|
/* make sure cursor is on screen */
|
||||||
|
|
|
||||||
|
|
@ -111,20 +111,13 @@ static void wps_format(char* fmt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wps_load_custom(char* file)
|
bool wps_load(char* file, bool display)
|
||||||
{
|
{
|
||||||
char buffer[FORMAT_BUFFER_SIZE];
|
char buffer[FORMAT_BUFFER_SIZE];
|
||||||
int fd;
|
int fd;
|
||||||
bool special = true;
|
|
||||||
|
|
||||||
wps_loaded = true;
|
wps_loaded = true;
|
||||||
|
|
||||||
/* default wps file? */
|
|
||||||
if (!file) {
|
|
||||||
file = WPS_CONFIG;
|
|
||||||
special = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
fd = open(file, O_RDONLY);
|
fd = open(file, O_RDONLY);
|
||||||
|
|
||||||
if (-1 != fd)
|
if (-1 != fd)
|
||||||
|
|
@ -139,7 +132,7 @@ bool wps_load_custom(char* file)
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
if ( special ) {
|
if ( display ) {
|
||||||
int i;
|
int i;
|
||||||
lcd_clear_display();
|
lcd_clear_display();
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
|
|
@ -640,8 +633,6 @@ void wps_display(struct mp3entry* id3)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!wps_loaded) {
|
if (!wps_loaded) {
|
||||||
wps_load_custom(NULL);
|
|
||||||
|
|
||||||
if ( !format_buffer[0] ) {
|
if ( !format_buffer[0] ) {
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
wps_format("%s%fp\n"
|
wps_format("%s%fp\n"
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
bool wps_refresh(struct mp3entry* id3, int ffwd_offset, bool refresh_scroll);
|
bool wps_refresh(struct mp3entry* id3, int ffwd_offset, bool refresh_scroll);
|
||||||
void wps_display(struct mp3entry* id3);
|
void wps_display(struct mp3entry* id3);
|
||||||
bool wps_load_custom(char* file);
|
bool wps_load(char* file, bool display);
|
||||||
|
|
||||||
#ifdef HAVE_LCD_CHARCELLS
|
#ifdef HAVE_LCD_CHARCELLS
|
||||||
bool draw_player_progress(struct mp3entry* id3, int ff_rewind_count);
|
bool draw_player_progress(struct mp3entry* id3, int ff_rewind_count);
|
||||||
|
|
|
||||||
|
|
@ -125,8 +125,6 @@ struct font* font_load(char *path)
|
||||||
char copyright[256+1];
|
char copyright[256+1];
|
||||||
struct font* pf = &font_ui;
|
struct font* pf = &font_ui;
|
||||||
|
|
||||||
memset(pf, 0, sizeof(struct font));
|
|
||||||
|
|
||||||
/* open and read entire font file*/
|
/* open and read entire font file*/
|
||||||
fd = open(path, O_RDONLY|O_BINARY);
|
fd = open(path, O_RDONLY|O_BINARY);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
|
|
@ -134,6 +132,8 @@ struct font* font_load(char *path)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset(pf, 0, sizeof(struct font));
|
||||||
|
|
||||||
/* currently, font loading replaces earlier font allocation*/
|
/* currently, font loading replaces earlier font allocation*/
|
||||||
freeptr = (unsigned char *)(((int)mbuf + 3) & ~3);
|
freeptr = (unsigned char *)(((int)mbuf + 3) & ~3);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue