diff options
author | Björn Stenberg <bjorn@haxx.se> | 2002-10-08 15:42:40 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2002-10-08 15:42:40 +0000 |
commit | dea31222b8318cd992f97cfe81b9c2239233f884 (patch) | |
tree | d7a0d7fcc0b34249322964d55b3cc6f6b2e7d3bd /apps | |
parent | b9d6830eddfa460d573f8af2020d17a9431dc056 (diff) | |
download | rockbox-dea31222b8318cd992f97cfe81b9c2239233f884.tar.gz rockbox-dea31222b8318cd992f97cfe81b9c2239233f884.zip |
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
Diffstat (limited to 'apps')
-rw-r--r-- | apps/main.c | 3 | ||||
-rw-r--r-- | apps/settings.c | 32 | ||||
-rw-r--r-- | apps/settings.h | 5 | ||||
-rw-r--r-- | apps/tree.c | 32 | ||||
-rw-r--r-- | apps/wps-display.c | 13 | ||||
-rw-r--r-- | apps/wps-display.h | 2 |
6 files changed, 73 insertions, 14 deletions
diff --git a/apps/main.c b/apps/main.c index 15bb73e971..d51b606d86 100644 --- a/apps/main.c +++ b/apps/main.c | |||
@@ -47,6 +47,7 @@ | |||
47 | #include "sprintf.h" | 47 | #include "sprintf.h" |
48 | #include "font.h" | 48 | #include "font.h" |
49 | #include "language.h" | 49 | #include "language.h" |
50 | #include "wps-display.h" | ||
50 | 51 | ||
51 | char appsversion[]=APPSVERSION; | 52 | char appsversion[]=APPSVERSION; |
52 | 53 | ||
@@ -68,6 +69,7 @@ void init(void) | |||
68 | show_logo(); | 69 | show_logo(); |
69 | settings_reset(); | 70 | settings_reset(); |
70 | settings_load(); | 71 | settings_load(); |
72 | wps_load(ROCKBOX_DIR "/default.wps", false); | ||
71 | font_load(ROCKBOX_DIR "/default.fnt"); | 73 | font_load(ROCKBOX_DIR "/default.fnt"); |
72 | lang_load(ROCKBOX_DIR "/default.lng"); | 74 | lang_load(ROCKBOX_DIR "/default.lng"); |
73 | sleep(HZ/2); | 75 | sleep(HZ/2); |
@@ -147,6 +149,7 @@ void init(void) | |||
147 | } | 149 | } |
148 | 150 | ||
149 | settings_load(); | 151 | settings_load(); |
152 | wps_load(ROCKBOX_DIR "/default.wps", false); | ||
150 | font_load(ROCKBOX_DIR "/default.fnt"); | 153 | font_load(ROCKBOX_DIR "/default.fnt"); |
151 | lang_load(ROCKBOX_DIR "/default.lng"); | 154 | lang_load(ROCKBOX_DIR "/default.lng"); |
152 | 155 | ||
diff --git a/apps/settings.c b/apps/settings.c index 067cc3eae4..f03c1e888b 100644 --- a/apps/settings.c +++ b/apps/settings.c | |||
@@ -45,8 +45,9 @@ | |||
45 | #include "icons.h" | 45 | #include "icons.h" |
46 | #include "font.h" | 46 | #include "font.h" |
47 | #endif | 47 | #endif |
48 | |||
49 | #include "lang.h" | 48 | #include "lang.h" |
49 | #include "language.h" | ||
50 | #include "wps-display.h" | ||
50 | 51 | ||
51 | struct user_settings global_settings; | 52 | struct user_settings global_settings; |
52 | char rockboxdir[] = ROCKBOX_DIR; /* config/font/data file directory */ | 53 | char rockboxdir[] = ROCKBOX_DIR; /* config/font/data file directory */ |
@@ -112,6 +113,9 @@ modified unless the header & checksum test fails. | |||
112 | 113 | ||
113 | Rest of config block, only saved to disk: | 114 | Rest of config block, only saved to disk: |
114 | 115 | ||
116 | 0xB8 (char[20]) WPS file | ||
117 | 0xCC (char[20]) Lang file | ||
118 | 0xE0 (char[20]) Font file | ||
115 | 0xF4 (int) Playlist first index | 119 | 0xF4 (int) Playlist first index |
116 | 0xF8 (int) Playlist shuffle seed | 120 | 0xF8 (int) Playlist shuffle seed |
117 | 0xFC (char[260]) Resume playlist (path/to/dir or path/to/playlist.m3u) | 121 | 0xFC (char[260]) Resume playlist (path/to/dir or path/to/playlist.m3u) |
@@ -313,6 +317,9 @@ int settings_save( void ) | |||
313 | 317 | ||
314 | memcpy(&config_block[0x24], &global_settings.total_uptime, 4); | 318 | memcpy(&config_block[0x24], &global_settings.total_uptime, 4); |
315 | 319 | ||
320 | strncpy(&config_block[0xb8], global_settings.wps_file, MAX_FILENAME); | ||
321 | strncpy(&config_block[0xcc], global_settings.lang_file, MAX_FILENAME); | ||
322 | strncpy(&config_block[0xe0], global_settings.font_file, MAX_FILENAME); | ||
316 | memcpy(&config_block[0xF4], &global_settings.resume_first_index, 4); | 323 | memcpy(&config_block[0xF4], &global_settings.resume_first_index, 4); |
317 | memcpy(&config_block[0xF8], &global_settings.resume_seed, 4); | 324 | memcpy(&config_block[0xF8], &global_settings.resume_seed, 4); |
318 | 325 | ||
@@ -345,6 +352,8 @@ int settings_save( void ) | |||
345 | 352 | ||
346 | void settings_apply(void) | 353 | void settings_apply(void) |
347 | { | 354 | { |
355 | char buf[64]; | ||
356 | |||
348 | mpeg_sound_set(SOUND_BASS, global_settings.bass); | 357 | mpeg_sound_set(SOUND_BASS, global_settings.bass); |
349 | mpeg_sound_set(SOUND_TREBLE, global_settings.treble); | 358 | mpeg_sound_set(SOUND_TREBLE, global_settings.treble); |
350 | mpeg_sound_set(SOUND_BALANCE, global_settings.balance); | 359 | mpeg_sound_set(SOUND_BALANCE, global_settings.balance); |
@@ -367,6 +376,24 @@ void settings_apply(void) | |||
367 | #ifdef HAVE_CHARGE_CTRL | 376 | #ifdef HAVE_CHARGE_CTRL |
368 | charge_restart_level = global_settings.discharge ? CHARGE_RESTART_LO : CHARGE_RESTART_HI; | 377 | charge_restart_level = global_settings.discharge ? CHARGE_RESTART_LO : CHARGE_RESTART_HI; |
369 | #endif | 378 | #endif |
379 | |||
380 | if ( global_settings.wps_file[0] ) { | ||
381 | snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.wps", | ||
382 | global_settings.wps_file); | ||
383 | wps_load(buf, false); | ||
384 | } | ||
385 | #ifdef HAVE_LCD_BITMAP | ||
386 | if ( global_settings.font_file[0] ) { | ||
387 | snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.fnt", | ||
388 | global_settings.font_file); | ||
389 | font_load(buf); | ||
390 | } | ||
391 | #endif | ||
392 | if ( global_settings.lang_file[0] ) { | ||
393 | snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.lng", | ||
394 | global_settings.lang_file); | ||
395 | lang_load(buf); | ||
396 | } | ||
370 | } | 397 | } |
371 | 398 | ||
372 | /* | 399 | /* |
@@ -473,6 +500,9 @@ void settings_load(void) | |||
473 | memcpy(&global_settings.resume_first_index, &config_block[0xF4], 4); | 500 | memcpy(&global_settings.resume_first_index, &config_block[0xF4], 4); |
474 | memcpy(&global_settings.resume_seed, &config_block[0xF8], 4); | 501 | memcpy(&global_settings.resume_seed, &config_block[0xF8], 4); |
475 | 502 | ||
503 | strncpy(global_settings.wps_file, &config_block[0xb8], MAX_FILENAME); | ||
504 | strncpy(global_settings.lang_file, &config_block[0xcc], MAX_FILENAME); | ||
505 | strncpy(global_settings.font_file, &config_block[0xe0], MAX_FILENAME); | ||
476 | strncpy(global_settings.resume_file, &config_block[0xFC], MAX_PATH); | 506 | strncpy(global_settings.resume_file, &config_block[0xFC], MAX_PATH); |
477 | global_settings.resume_file[MAX_PATH]=0; | 507 | global_settings.resume_file[MAX_PATH]=0; |
478 | } | 508 | } |
diff --git a/apps/settings.h b/apps/settings.h index f5609fe75c..c2f5c925fb 100644 --- a/apps/settings.h +++ b/apps/settings.h | |||
@@ -25,6 +25,8 @@ | |||
25 | 25 | ||
26 | #define ROCKBOX_DIR "/.rockbox" | 26 | #define ROCKBOX_DIR "/.rockbox" |
27 | 27 | ||
28 | #define MAX_FILENAME 20 | ||
29 | |||
28 | /* data structures */ | 30 | /* data structures */ |
29 | 31 | ||
30 | #define RESUME_OFF 0 | 32 | #define RESUME_OFF 0 |
@@ -75,6 +77,9 @@ struct user_settings | |||
75 | int resume_seed; /* random seed for playlist shuffle */ | 77 | int resume_seed; /* random seed for playlist shuffle */ |
76 | int resume_first_index; /* first index of playlist */ | 78 | int resume_first_index; /* first index of playlist */ |
77 | unsigned char resume_file[MAX_PATH+1]; /* playlist name (or dir) */ | 79 | unsigned char resume_file[MAX_PATH+1]; /* playlist name (or dir) */ |
80 | unsigned char font_file[MAX_FILENAME+1]; /* last font */ | ||
81 | unsigned char wps_file[MAX_FILENAME+1]; /* last wps */ | ||
82 | unsigned char lang_file[MAX_FILENAME+1]; /* last language */ | ||
78 | 83 | ||
79 | /* misc options */ | 84 | /* misc options */ |
80 | 85 | ||
diff --git a/apps/tree.c b/apps/tree.c index e5c515f06b..6e52942b45 100644 --- a/apps/tree.c +++ b/apps/tree.c | |||
@@ -658,6 +658,26 @@ bool pageupdown(int* ds, int* dc, int numentries, int tree_max_on_screen ) | |||
658 | } | 658 | } |
659 | #endif | 659 | #endif |
660 | 660 | ||
661 | static void storefile(char* filename, char* setting, int maxlen) | ||
662 | { | ||
663 | int len = strlen(filename); | ||
664 | int extlen = 0; | ||
665 | char* ptr = filename + len; | ||
666 | |||
667 | while (*ptr != '.') { | ||
668 | extlen++; | ||
669 | ptr--; | ||
670 | } | ||
671 | |||
672 | if (strcmp(ROCKBOX_DIR, currdir) || (len > maxlen-extlen)) | ||
673 | return; | ||
674 | |||
675 | strncpy(setting, filename, len-extlen); | ||
676 | setting[len-extlen]=0; | ||
677 | |||
678 | settings_save(); | ||
679 | } | ||
680 | |||
661 | bool dirbrowse(char *root) | 681 | bool dirbrowse(char *root) |
662 | { | 682 | { |
663 | int numentries=0; | 683 | int numentries=0; |
@@ -771,6 +791,7 @@ bool dirbrowse(char *root) | |||
771 | int seed = current_tick; | 791 | int seed = current_tick; |
772 | bool play = false; | 792 | bool play = false; |
773 | int start_index=0; | 793 | int start_index=0; |
794 | |||
774 | lcd_stop_scroll(); | 795 | lcd_stop_scroll(); |
775 | switch ( file->attr & TREE_ATTR_MASK ) { | 796 | switch ( file->attr & TREE_ATTR_MASK ) { |
776 | case TREE_ATTR_M3U: | 797 | case TREE_ATTR_M3U: |
@@ -802,7 +823,9 @@ bool dirbrowse(char *root) | |||
802 | case TREE_ATTR_WPS: | 823 | case TREE_ATTR_WPS: |
803 | snprintf(buf, sizeof buf, "%s/%s", | 824 | snprintf(buf, sizeof buf, "%s/%s", |
804 | currdir, file->name); | 825 | currdir, file->name); |
805 | wps_load_custom(buf); | 826 | wps_load(buf,true); |
827 | storefile(file->name, global_settings.wps_file, | ||
828 | MAX_FILENAME); | ||
806 | restore = true; | 829 | restore = true; |
807 | break; | 830 | break; |
808 | 831 | ||
@@ -824,6 +847,10 @@ bool dirbrowse(char *root) | |||
824 | snprintf(buf, sizeof buf, "%s/%s", | 847 | snprintf(buf, sizeof buf, "%s/%s", |
825 | currdir, file->name); | 848 | currdir, file->name); |
826 | if(!lang_load(buf)) { | 849 | if(!lang_load(buf)) { |
850 | storefile(file->name, | ||
851 | global_settings.lang_file, | ||
852 | MAX_FILENAME); | ||
853 | |||
827 | lcd_clear_display(); | 854 | lcd_clear_display(); |
828 | #ifdef HAVE_LCD_CHARCELLS | 855 | #ifdef HAVE_LCD_CHARCELLS |
829 | lcd_puts(0, 0, str(LANG_LANGUAGE_LOADED)); | 856 | lcd_puts(0, 0, str(LANG_LANGUAGE_LOADED)); |
@@ -849,6 +876,9 @@ bool dirbrowse(char *root) | |||
849 | snprintf(buf, sizeof buf, "%s/%s", | 876 | snprintf(buf, sizeof buf, "%s/%s", |
850 | currdir, file->name); | 877 | currdir, file->name); |
851 | font_load(buf); | 878 | font_load(buf); |
879 | storefile(file->name, global_settings.font_file, | ||
880 | MAX_FILENAME); | ||
881 | |||
852 | lcd_getstringsize("A", &fw, &fh); | 882 | lcd_getstringsize("A", &fw, &fh); |
853 | tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh; | 883 | tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh; |
854 | /* make sure cursor is on screen */ | 884 | /* make sure cursor is on screen */ |
diff --git a/apps/wps-display.c b/apps/wps-display.c index 3f94a09b9e..b629a06c4e 100644 --- a/apps/wps-display.c +++ b/apps/wps-display.c | |||
@@ -111,20 +111,13 @@ static void wps_format(char* fmt) | |||
111 | } | 111 | } |
112 | } | 112 | } |
113 | 113 | ||
114 | bool wps_load_custom(char* file) | 114 | bool wps_load(char* file, bool display) |
115 | { | 115 | { |
116 | char buffer[FORMAT_BUFFER_SIZE]; | 116 | char buffer[FORMAT_BUFFER_SIZE]; |
117 | int fd; | 117 | int fd; |
118 | bool special = true; | ||
119 | 118 | ||
120 | wps_loaded = true; | 119 | wps_loaded = true; |
121 | 120 | ||
122 | /* default wps file? */ | ||
123 | if (!file) { | ||
124 | file = WPS_CONFIG; | ||
125 | special = false; | ||
126 | } | ||
127 | |||
128 | fd = open(file, O_RDONLY); | 121 | fd = open(file, O_RDONLY); |
129 | 122 | ||
130 | if (-1 != fd) | 123 | if (-1 != fd) |
@@ -139,7 +132,7 @@ bool wps_load_custom(char* file) | |||
139 | 132 | ||
140 | close(fd); | 133 | close(fd); |
141 | 134 | ||
142 | if ( special ) { | 135 | if ( display ) { |
143 | int i; | 136 | int i; |
144 | lcd_clear_display(); | 137 | lcd_clear_display(); |
145 | #ifdef HAVE_LCD_BITMAP | 138 | #ifdef HAVE_LCD_BITMAP |
@@ -640,8 +633,6 @@ void wps_display(struct mp3entry* id3) | |||
640 | else | 633 | else |
641 | { | 634 | { |
642 | if (!wps_loaded) { | 635 | if (!wps_loaded) { |
643 | wps_load_custom(NULL); | ||
644 | |||
645 | if ( !format_buffer[0] ) { | 636 | if ( !format_buffer[0] ) { |
646 | #ifdef HAVE_LCD_BITMAP | 637 | #ifdef HAVE_LCD_BITMAP |
647 | wps_format("%s%fp\n" | 638 | wps_format("%s%fp\n" |
diff --git a/apps/wps-display.h b/apps/wps-display.h index a62817edad..439660e831 100644 --- a/apps/wps-display.h +++ b/apps/wps-display.h | |||
@@ -24,7 +24,7 @@ | |||
24 | 24 | ||
25 | bool wps_refresh(struct mp3entry* id3, int ffwd_offset, bool refresh_scroll); | 25 | bool wps_refresh(struct mp3entry* id3, int ffwd_offset, bool refresh_scroll); |
26 | void wps_display(struct mp3entry* id3); | 26 | void wps_display(struct mp3entry* id3); |
27 | bool wps_load_custom(char* file); | 27 | bool wps_load(char* file, bool display); |
28 | 28 | ||
29 | #ifdef HAVE_LCD_CHARCELLS | 29 | #ifdef HAVE_LCD_CHARCELLS |
30 | bool draw_player_progress(struct mp3entry* id3, int ff_rewind_count); | 30 | bool draw_player_progress(struct mp3entry* id3, int ff_rewind_count); |