summaryrefslogtreecommitdiff
path: root/apps/gui/skin_engine/skin_display.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui/skin_engine/skin_display.c')
-rw-r--r--apps/gui/skin_engine/skin_display.c144
1 files changed, 1 insertions, 143 deletions
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c
index 8638d2c902..24e976d393 100644
--- a/apps/gui/skin_engine/skin_display.c
+++ b/apps/gui/skin_engine/skin_display.c
@@ -349,149 +349,7 @@ void wps_display_images(struct gui_wps *gwps, struct viewport* vp)
349 display->set_drawmode(DRMODE_SOLID); 349 display->set_drawmode(DRMODE_SOLID);
350} 350}
351 351
352#else /* HAVE_LCD_CHARCELL */ 352#endif /* HAVE_LCD_BITMAP */
353
354bool draw_player_progress(struct gui_wps *gwps)
355{
356 struct wps_state *state = skin_get_global_state();
357 struct screen *display = gwps->display;
358 unsigned char progress_pattern[7];
359 int pos = 0;
360 int i;
361
362 int elapsed, length;
363 if (LIKELY(state->id3))
364 {
365 elapsed = state->id3->elapsed;
366 length = state->id3->length;
367 }
368 else
369 {
370 elapsed = 0;
371 length = 0;
372 }
373
374 if (length)
375 pos = 36 * (elapsed + state->ff_rewind_count) / length;
376
377 for (i = 0; i < 7; i++, pos -= 5)
378 {
379 if (pos <= 0)
380 progress_pattern[i] = 0x1fu;
381 else if (pos >= 5)
382 progress_pattern[i] = 0x00u;
383 else
384 progress_pattern[i] = 0x1fu >> pos;
385 }
386
387 display->define_pattern(gwps->data->wps_progress_pat[0], progress_pattern);
388 return true;
389}
390
391void draw_player_fullbar(struct gui_wps *gwps, char* buf, int buf_size)
392{
393 static const unsigned char numbers[10][4] = {
394 {0x0e, 0x0a, 0x0a, 0x0e}, /* 0 */
395 {0x04, 0x0c, 0x04, 0x04}, /* 1 */
396 {0x0e, 0x02, 0x04, 0x0e}, /* 2 */
397 {0x0e, 0x02, 0x06, 0x0e}, /* 3 */
398 {0x08, 0x0c, 0x0e, 0x04}, /* 4 */
399 {0x0e, 0x0c, 0x02, 0x0c}, /* 5 */
400 {0x0e, 0x08, 0x0e, 0x0e}, /* 6 */
401 {0x0e, 0x02, 0x04, 0x08}, /* 7 */
402 {0x0e, 0x0e, 0x0a, 0x0e}, /* 8 */
403 {0x0e, 0x0e, 0x02, 0x0e}, /* 9 */
404 };
405
406 struct wps_state *state = skin_get_global_state();
407 struct screen *display = gwps->display;
408 struct wps_data *data = gwps->data;
409 unsigned char progress_pattern[7];
410 char timestr[10];
411 int time;
412 int time_idx = 0;
413 int pos = 0;
414 int pat_idx = 1;
415 int digit, i, j;
416 bool softchar;
417
418 int elapsed, length;
419 if (LIKELY(state->id3))
420 {
421 elapsed = state->id3->elapsed;
422 length = state->id3->length;
423 }
424 else
425 {
426 elapsed = 0;
427 length = 0;
428 }
429
430 if (buf_size < 34) /* worst case: 11x UTF-8 char + \0 */
431 return;
432
433 time = elapsed + state->ff_rewind_count;
434 if (length)
435 pos = 55 * time / length;
436
437 memset(timestr, 0, sizeof(timestr));
438 format_time(timestr, sizeof(timestr)-2, time);
439 timestr[strlen(timestr)] = ':'; /* always safe */
440
441 for (i = 0; i < 11; i++, pos -= 5)
442 {
443 softchar = false;
444 memset(progress_pattern, 0, sizeof(progress_pattern));
445
446 if ((digit = timestr[time_idx]))
447 {
448 softchar = true;
449 digit -= '0';
450
451 if (timestr[time_idx + 1] == ':') /* ones, left aligned */
452 {
453 memcpy(progress_pattern, numbers[digit], 4);
454 time_idx += 2;
455 }
456 else /* tens, shifted right */
457 {
458 for (j = 0; j < 4; j++)
459 progress_pattern[j] = numbers[digit][j] >> 1;
460
461 if (time_idx > 0) /* not the first group, add colon in front */
462 {
463 progress_pattern[1] |= 0x10u;
464 progress_pattern[3] |= 0x10u;
465 }
466 time_idx++;
467 }
468
469 if (pos >= 5)
470 progress_pattern[5] = progress_pattern[6] = 0x1fu;
471 }
472
473 if (pos > 0 && pos < 5)
474 {
475 softchar = true;
476 progress_pattern[5] = progress_pattern[6] = (~0x1fu >> pos) & 0x1fu;
477 }
478
479 if (softchar && pat_idx < 8)
480 {
481 display->define_pattern(data->wps_progress_pat[pat_idx],
482 progress_pattern);
483 buf = utf8encode(data->wps_progress_pat[pat_idx], buf);
484 pat_idx++;
485 }
486 else if (pos <= 0)
487 buf = utf8encode(' ', buf);
488 else
489 buf = utf8encode(0xe115, buf); /* 2/7 _ */
490 }
491 *buf = '\0';
492}
493
494#endif /* HAVE_LCD_CHARCELL */
495 353
496/* Evaluate the conditional that is at *token_index and return whether a skip 354/* Evaluate the conditional that is at *token_index and return whether a skip
497 has ocurred. *token_index is updated with the new position. 355 has ocurred. *token_index is updated with the new position.