Skip to content

Commit

Permalink
Add a background texture. Animate during nandroids. Fix dir count.
Browse files Browse the repository at this point in the history
Change-Id: I9d03f72453d20ba8647b6f81821bf71004621011
  • Loading branch information
koush committed Jul 16, 2012
1 parent c222b70 commit 79b3194
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 9 deletions.
1 change: 1 addition & 0 deletions common.h
Expand Up @@ -42,6 +42,7 @@ void ui_set_nice(int enabled);
#define ui_nice_print(...) { ui_set_nice(1); ui_print(__VA_ARGS__); ui_set_nice(0); } #define ui_nice_print(...) { ui_set_nice(1); ui_print(__VA_ARGS__); ui_set_nice(0); }
int ui_was_niced(); int ui_was_niced();
int ui_get_text_cols(); int ui_get_text_cols();
void ui_increment_frame();


// Display some header text followed by a menu of items, which appears // Display some header text followed by a menu of items, which appears
// at the top of the screen (in place of any scrolling ui_print() // at the top of the screen (in place of any scrolling ui_print()
Expand Down
3 changes: 2 additions & 1 deletion nandroid.c
Expand Up @@ -78,6 +78,7 @@ static void nandroid_callback(const char* filename)
tmp[strlen(tmp) - 1] = NULL; tmp[strlen(tmp) - 1] = NULL;
tmp[ui_get_text_cols() - 1] = '\0'; tmp[ui_get_text_cols() - 1] = '\0';
nandroid_files_count++; nandroid_files_count++;
ui_increment_frame();
ui_nice_print("%s\n", tmp); ui_nice_print("%s\n", tmp);
if (!ui_was_niced() && nandroid_files_total != 0) if (!ui_was_niced() && nandroid_files_total != 0)
ui_set_progress((float)nandroid_files_count / (float)nandroid_files_total); ui_set_progress((float)nandroid_files_count / (float)nandroid_files_total);
Expand All @@ -88,7 +89,7 @@ static void nandroid_callback(const char* filename)
static void compute_directory_stats(const char* directory) static void compute_directory_stats(const char* directory)
{ {
char tmp[PATH_MAX]; char tmp[PATH_MAX];
sprintf(tmp, "find %s | wc -l > /tmp/dircount", directory); sprintf(tmp, "find %s | %s wc -l > /tmp/dircount", directory, strcmp(directory, "/data") == 0 && is_data_media() ? "grep -v /data/media |" : "");
__system(tmp); __system(tmp);
char count_text[100]; char count_text[100];
FILE* f = fopen("/tmp/dircount", "r"); FILE* f = fopen("/tmp/dircount", "r");
Expand Down
Binary file modified res/images/icon_installing.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/images/icon_installing_overlay01.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/images/icon_installing_overlay02.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/images/icon_installing_overlay03.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/images/icon_installing_overlay04.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/images/icon_installing_overlay05.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/images/icon_installing_overlay06.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/images/icon_installing_overlay07.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/images/stitch.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 23 additions & 8 deletions ui.c
Expand Up @@ -70,6 +70,7 @@ static gr_surface *gInstallationOverlay;
static gr_surface *gProgressBarIndeterminate; static gr_surface *gProgressBarIndeterminate;
static gr_surface gProgressBarEmpty; static gr_surface gProgressBarEmpty;
static gr_surface gProgressBarFill; static gr_surface gProgressBarFill;
static gr_surface gBackground;
static int ui_has_initialized = 0; static int ui_has_initialized = 0;
static int ui_log_stdout = 1; static int ui_log_stdout = 1;


Expand All @@ -84,6 +85,7 @@ static const struct { gr_surface* surface; const char *name; } BITMAPS[] = {
{ &gBackgroundIcon[BACKGROUND_ICON_FIRMWARE_ERROR], "icon_firmware_error" }, { &gBackgroundIcon[BACKGROUND_ICON_FIRMWARE_ERROR], "icon_firmware_error" },
{ &gProgressBarEmpty, "progress_empty" }, { &gProgressBarEmpty, "progress_empty" },
{ &gProgressBarFill, "progress_fill" }, { &gProgressBarFill, "progress_fill" },
{ &gBackground, "stitch" },
{ NULL, NULL }, { NULL, NULL },
}; };


Expand Down Expand Up @@ -156,8 +158,20 @@ static void draw_install_overlay_locked(int frame) {
static void draw_background_locked(int icon) static void draw_background_locked(int icon)
{ {
gPagesIdentical = 0; gPagesIdentical = 0;
gr_color(0, 0, 0, 255); // gr_color(0, 0, 0, 255);
gr_fill(0, 0, gr_fb_width(), gr_fb_height()); // gr_fill(0, 0, gr_fb_width(), gr_fb_height());

{
int bw = gr_get_width(gBackground);
int bh = gr_get_height(gBackground);
int bx = 0;
int by = 0;
for (by = 0; by < gr_fb_height(); by += bh) {
for (bx = 0; bx < gr_fb_width(); bx += bw) {
gr_blit(gBackground, 0, 0, bw, bh, bx, by);
}
}
}


if (icon) { if (icon) {
gr_surface surface = gBackgroundIcon[icon]; gr_surface surface = gBackgroundIcon[icon];
Expand Down Expand Up @@ -680,19 +694,15 @@ void ui_print(const char *fmt, ...)
struct timeval curtime; struct timeval curtime;
gettimeofday(&curtime, NULL); gettimeofday(&curtime, NULL);
long ms = delta_milliseconds(lastupdate, curtime); long ms = delta_milliseconds(lastupdate, curtime);
if (ms < 0) { if (ms < NICE_INTERVAL && ms >= 0) {
lastupdate = curtime;
ms = NICE_INTERVAL;
}
if (ms < NICE_INTERVAL) {
ui_niced = 1; ui_niced = 1;
return; return;
} }
lastupdate = curtime;
} }


// This can get called before ui_init(), so be careful. // This can get called before ui_init(), so be careful.
pthread_mutex_lock(&gUpdateMutex); pthread_mutex_lock(&gUpdateMutex);
gettimeofday(&lastupdate, NULL);
if (text_rows > 0 && text_cols > 0) { if (text_rows > 0 && text_cols > 0) {
char *ptr; char *ptr;
for (ptr = buf; *ptr != '\0'; ++ptr) { for (ptr = buf; *ptr != '\0'; ++ptr) {
Expand Down Expand Up @@ -990,3 +1000,8 @@ void ui_delete_line() {
text_col = 0; text_col = 0;
pthread_mutex_unlock(&gUpdateMutex); pthread_mutex_unlock(&gUpdateMutex);
} }

void ui_increment_frame() {
gInstallingFrame =
(gInstallingFrame + 1) % ui_parameters.installing_frames;
}

0 comments on commit 79b3194

Please sign in to comment.