diff options
Diffstat (limited to 'apps/plugins/credits.c')
-rw-r--r-- | apps/plugins/credits.c | 197 |
1 files changed, 158 insertions, 39 deletions
diff --git a/apps/plugins/credits.c b/apps/plugins/credits.c index b726771edc..52c0394367 100644 --- a/apps/plugins/credits.c +++ b/apps/plugins/credits.c | |||
@@ -35,6 +35,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
35 | (void)parameter; | 35 | (void)parameter; |
36 | rb = api; | 36 | rb = api; |
37 | 37 | ||
38 | rb->backlight_set_timeout(1); | ||
39 | |||
38 | rb->show_logo(); | 40 | rb->show_logo(); |
39 | #ifdef HAVE_LCD_CHARCELLS | 41 | #ifdef HAVE_LCD_CHARCELLS |
40 | rb->lcd_double_height(false); | 42 | rb->lcd_double_height(false); |
@@ -50,15 +52,18 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
50 | 52 | ||
51 | roll_credits(); | 53 | roll_credits(); |
52 | 54 | ||
55 | rb->backlight_set_timeout(rb->global_settings->backlight_timeout); | ||
56 | |||
53 | return PLUGIN_OK; | 57 | return PLUGIN_OK; |
54 | } | 58 | } |
55 | 59 | ||
56 | #ifdef HAVE_LCD_CHARCELLS | 60 | #ifdef HAVE_LCD_CHARCELLS |
61 | |||
57 | void roll_credits(void) | 62 | void roll_credits(void) |
58 | { | 63 | { |
59 | int numnames = sizeof(credits)/sizeof(char*); | 64 | int numnames = sizeof(credits)/sizeof(char*); |
60 | int curr_name = 0; | 65 | int curr_name = 0; |
61 | int curr_len = rb->utf8length(credits[0]); | 66 | int curr_len = utf8length(credits[0]); |
62 | int curr_index = 0; | 67 | int curr_index = 0; |
63 | int curr_line = 0; | 68 | int curr_line = 0; |
64 | int name, len, new_len, line, x; | 69 | int name, len, new_len, line, x; |
@@ -77,7 +82,7 @@ void roll_credits(void) | |||
77 | int x2; | 82 | int x2; |
78 | 83 | ||
79 | if (x < 0) | 84 | if (x < 0) |
80 | rb->lcd_puts(0, line, credits[name] + rb->utf8seek(credits[name], -x)); | 85 | rb->lcd_puts(0, line, credits[name] + utf8seek(credits[name], -x)); |
81 | else | 86 | else |
82 | rb->lcd_puts(x, line, credits[name]); | 87 | rb->lcd_puts(x, line, credits[name]); |
83 | 88 | ||
@@ -90,7 +95,7 @@ void roll_credits(void) | |||
90 | if ((unsigned)x2 < 11) | 95 | if ((unsigned)x2 < 11) |
91 | rb->lcd_putc(x2, line, '*'); | 96 | rb->lcd_putc(x2, line, '*'); |
92 | 97 | ||
93 | new_len = rb->utf8length(credits[name]); | 98 | new_len = utf8length(credits[name]); |
94 | x += MAX(len/2 + 2, len - new_len/2 + 1); | 99 | x += MAX(len/2 + 2, len - new_len/2 + 1); |
95 | len = new_len; | 100 | len = new_len; |
96 | } | 101 | } |
@@ -102,67 +107,181 @@ void roll_credits(void) | |||
102 | { | 107 | { |
103 | if (++curr_name >= numnames) | 108 | if (++curr_name >= numnames) |
104 | break; | 109 | break; |
105 | new_len = rb->utf8length(credits[curr_name]); | 110 | new_len = utf8length(credits[curr_name]); |
106 | curr_index -= MAX(curr_len/2 + 2, curr_len - new_len/2 + 1); | 111 | curr_index -= MAX(curr_len/2 + 2, curr_len - new_len/2 + 1); |
107 | curr_len = new_len; | 112 | curr_len = new_len; |
108 | curr_line ^= 1; | 113 | curr_line ^= 1; |
109 | } | 114 | } |
110 | } | 115 | } |
111 | } | 116 | } |
112 | #else | ||
113 | 117 | ||
114 | static int minisin[]={ | ||
115 | #if 1 | ||
116 | 1, 2, 2, 3, 3, 3, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0 | ||
117 | #else | 118 | #else |
118 | 1, 2, 3, 4, 4, 4, 3, 2, 1, 0, 0, -1, -1, -1, 0, 0, | ||
119 | #endif | ||
120 | }; | ||
121 | 119 | ||
122 | void roll_credits(void) | 120 | void roll_credits(void) |
123 | { | 121 | { |
124 | int i; | 122 | #if (CONFIG_KEYPAD == RECORDER_PAD) |
125 | int line = 0; | 123 | #define PAUSE_TIME 1.2 |
126 | int numnames = sizeof(credits)/sizeof(char*); | 124 | #define ANIM_SPEED 35 |
127 | char buffer[40]; | 125 | #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) |
126 | #define PAUSE_TIME 0 | ||
127 | #define ANIM_SPEED 100 | ||
128 | #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) | ||
129 | #define PAUSE_TIME 0 | ||
130 | #define ANIM_SPEED 35 | ||
131 | #else | ||
132 | #define PAUSE_TIME 1 | ||
133 | #define ANIM_SPEED 40 | ||
134 | #endif | ||
128 | 135 | ||
129 | int y=LCD_HEIGHT; | 136 | #define NUM_VISIBLE_LINES (LCD_HEIGHT/font_h - 1) |
137 | #define CREDITS_TARGETPOS ((LCD_WIDTH/2)-(credits_w/2)) | ||
130 | 138 | ||
131 | int height; | 139 | int i=0, j=0, namepos=0, offset_dummy, btn; |
132 | int width; | 140 | int name_w, name_h, name_targetpos=1, font_h; |
133 | int sinstep=0; | 141 | int credits_w, credits_pos; |
142 | int numnames = (sizeof(credits)/sizeof(char*)); | ||
143 | char name[40], elapsednames[20]; | ||
134 | 144 | ||
135 | rb->lcd_setfont(FONT_UI); | 145 | rb->lcd_setfont(FONT_UI); |
146 | rb->lcd_clear_display(); | ||
147 | rb->lcd_update(); | ||
136 | 148 | ||
137 | rb->lcd_getstringsize((unsigned char *)"A", &width, &height); | 149 | rb->lcd_getstringsize("A", NULL, &font_h); |
138 | 150 | ||
139 | while(1) { | 151 | /* snprintf "credits" text, and save the width and height */ |
140 | rb->lcd_clear_display(); | 152 | rb->snprintf(elapsednames, sizeof(elapsednames), "[Credits] %d/%d", |
141 | for ( i=0; i <= (LCD_HEIGHT-y)/height; i++ ) | 153 | j+1, numnames); |
142 | rb->lcd_putsxy(0, i*height+y, | 154 | rb->lcd_getstringsize(elapsednames, &credits_w, NULL); |
143 | (unsigned char *)(line+i<numnames?credits[line+i]:"")); | 155 | |
144 | rb->snprintf(buffer, sizeof(buffer), " [Credits] %2d/%2d ", | 156 | /* fly in "credits" text from the left */ |
145 | line+1, numnames); | 157 | for(credits_pos = 0 - credits_w; credits_pos <= CREDITS_TARGETPOS; |
158 | credits_pos += (CREDITS_TARGETPOS-credits_pos + 14) / 7) | ||
159 | { | ||
146 | rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | 160 | rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); |
147 | rb->lcd_fillrect(0, 0, LCD_WIDTH, height); | 161 | rb->lcd_fillrect(0, 0, LCD_WIDTH, font_h); |
148 | rb->lcd_set_drawmode(DRMODE_SOLID); | 162 | rb->lcd_set_drawmode(DRMODE_SOLID); |
149 | rb->lcd_putsxy(0, 0, (unsigned char *)buffer); | 163 | rb->lcd_putsxy(credits_pos, 0, elapsednames); |
150 | rb->lcd_update(); | 164 | rb->lcd_update_rect(0, 0, LCD_WIDTH, font_h); |
165 | rb->sleep(HZ/ANIM_SPEED); | ||
166 | } | ||
151 | 167 | ||
152 | if (rb->button_get_w_tmo(HZ/20) & BUTTON_REL) | 168 | /* first screen's worth of lines fly in */ |
153 | return; | 169 | for(i=0; i<NUM_VISIBLE_LINES; i++) |
170 | { | ||
171 | rb->snprintf(name, sizeof(name), "%s", credits[i]); | ||
172 | rb->lcd_getstringsize(name, &name_w, &name_h); | ||
173 | |||
174 | rb->snprintf(elapsednames, sizeof(elapsednames), "[Credits] %d/%d", | ||
175 | i+1, numnames); | ||
176 | rb->lcd_getstringsize(elapsednames, &credits_w, NULL); | ||
177 | rb->lcd_putsxy(CREDITS_TARGETPOS, 0, elapsednames); | ||
154 | 178 | ||
155 | y-= minisin[sinstep]; | 179 | for(namepos = 0-name_w; namepos <= name_targetpos; |
156 | sinstep++; | 180 | namepos += (name_targetpos - namepos + 14) / 7) |
157 | sinstep &= 0x0f; /* wrap */ | 181 | { |
182 | rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | ||
183 | rb->lcd_fillrect(0, font_h*(i+1), LCD_WIDTH, font_h); /* clear any trails left behind */ | ||
184 | rb->lcd_set_drawmode(DRMODE_SOLID); | ||
185 | rb->lcd_putsxy(namepos, font_h*(i+1), name); | ||
186 | rb->lcd_update_rect(0, font_h*(i+1), LCD_WIDTH, font_h); | ||
187 | rb->lcd_update_rect(CREDITS_TARGETPOS, 0, credits_w, font_h); | ||
158 | 188 | ||
159 | if(y<0) { | 189 | /* exit on keypress */ |
160 | line++; | 190 | btn = rb->button_get_w_tmo(HZ/ANIM_SPEED); |
161 | if(line >= numnames) | 191 | if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) |
192 | return; | ||
193 | } | ||
194 | } | ||
195 | j+=i; | ||
196 | |||
197 | /* pause for a bit if needed */ | ||
198 | btn = rb->button_get_w_tmo(HZ*PAUSE_TIME); /* exit on keypress */ | ||
199 | if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) | ||
200 | return; | ||
201 | |||
202 | /* now begin looping the in-out animation */ | ||
203 | while(j < numnames) | ||
204 | { | ||
205 | /* just a screen's worth at a time */ | ||
206 | for(i=0; i<NUM_VISIBLE_LINES; i++) | ||
207 | { | ||
208 | if(j+i >= numnames) | ||
162 | break; | 209 | break; |
163 | y+=height; | 210 | |
211 | offset_dummy=1; | ||
212 | |||
213 | rb->snprintf(name, sizeof(name), "%s", credits[j+i-NUM_VISIBLE_LINES]); | ||
214 | rb->lcd_getstringsize(name, &name_w, &name_h); | ||
215 | |||
216 | /* fly out an existing line.. */ | ||
217 | while(namepos<LCD_WIDTH+offset_dummy) | ||
218 | { | ||
219 | rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | ||
220 | rb->lcd_fillrect(0, font_h*(i+1), LCD_WIDTH, font_h); /* clear trails */ | ||
221 | rb->lcd_set_drawmode(DRMODE_SOLID); | ||
222 | rb->lcd_putsxy(namepos, font_h*(i+1), name); | ||
223 | rb->lcd_update_rect(0, font_h*(i+1), LCD_WIDTH, font_h); | ||
224 | |||
225 | /* exit on keypress */ | ||
226 | btn = rb->button_get_w_tmo(HZ/ANIM_SPEED); | ||
227 | if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) | ||
228 | return; | ||
229 | |||
230 | namepos += offset_dummy; | ||
231 | offset_dummy++; | ||
232 | } | ||
233 | |||
234 | rb->snprintf(name, sizeof(name), "%s", credits[j+i]); | ||
235 | rb->lcd_getstringsize(name, &name_w, &name_h); | ||
236 | |||
237 | rb->snprintf(elapsednames, sizeof(elapsednames), "[Credits] %d/%d", | ||
238 | j+i+1, numnames); | ||
239 | rb->lcd_getstringsize(elapsednames, &credits_w, NULL); | ||
240 | rb->lcd_putsxy(CREDITS_TARGETPOS, 0, elapsednames); | ||
241 | |||
242 | for(namepos = 0-name_w; namepos <= name_targetpos; | ||
243 | namepos += (name_targetpos - namepos + 14) / 7) | ||
244 | { | ||
245 | rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | ||
246 | rb->lcd_fillrect(0, font_h*(i+1), LCD_WIDTH, font_h); | ||
247 | rb->lcd_set_drawmode(DRMODE_SOLID); | ||
248 | rb->lcd_putsxy(namepos, font_h*(i+1), name); | ||
249 | rb->lcd_update_rect(0, font_h*(i+1), LCD_WIDTH, font_h); | ||
250 | rb->lcd_update_rect(CREDITS_TARGETPOS, 0, credits_w, font_h); | ||
251 | |||
252 | /* exit on keypress */ | ||
253 | btn = rb->button_get_w_tmo(HZ/ANIM_SPEED); | ||
254 | if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) | ||
255 | return; | ||
256 | } | ||
257 | |||
258 | namepos = name_targetpos; | ||
259 | |||
260 | /* ..and repeat. */ | ||
164 | } | 261 | } |
262 | j+=i; | ||
165 | 263 | ||
264 | btn = rb->button_get_w_tmo(HZ*PAUSE_TIME); /* exit on keypress */ | ||
265 | if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) | ||
266 | return; | ||
267 | } | ||
268 | |||
269 | btn = rb->button_get_w_tmo(HZ); /* exit on keypress */ | ||
270 | if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) | ||
271 | return; | ||
272 | |||
273 | offset_dummy = 1; | ||
274 | |||
275 | /* now make the text exit to the right */ | ||
276 | for(credits_pos = (LCD_WIDTH/2)-(credits_w/2); credits_pos <= LCD_WIDTH+offset_dummy; | ||
277 | credits_pos += offset_dummy, offset_dummy++) | ||
278 | { | ||
279 | rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | ||
280 | rb->lcd_fillrect(0, 0, LCD_WIDTH, font_h); | ||
281 | rb->lcd_set_drawmode(DRMODE_SOLID); | ||
282 | rb->lcd_putsxy(credits_pos, 0, elapsednames); | ||
283 | rb->lcd_update(); | ||
166 | } | 284 | } |
167 | } | 285 | } |
286 | |||
168 | #endif | 287 | #endif |