From: skeezix Date: Thu, 15 Apr 2010 20:09:56 +0000 (-0400) Subject: Added minimenu about screen; mmenu dir browser will not try to real time pick up... X-Git-Tag: Release-2010-05/1~15 X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?p=pandora-libraries.git;a=commitdiff_plain;h=4aefc132224a6a4d9554a0cf151a3c5bfa8380df Added minimenu about screen; mmenu dir browser will not try to real time pick up icons from pnd files when opening a directory full of them --- diff --git a/minimenu/mmcache.c b/minimenu/mmcache.c index c5682f2..bc98c68 100644 --- a/minimenu/mmcache.c +++ b/minimenu/mmcache.c @@ -240,7 +240,22 @@ unsigned char cache_icon ( pnd_disco_t *app, unsigned char maxwidth, unsigned ch } // ovr? // if this is a real pnd file (dir-app or pnd-file-app), then try to pull icon from there - if ( ! ( app -> object_flags & PND_DISCO_GENERATED ) ) { + if ( app -> object_flags & PND_DISCO_GENERATED ) { + + // maybe we can discover this single-file and find an icon? + if ( strcasestr ( app -> object_filename, PND_PACKAGE_FILEEXT ) ) { + + // looks like a pnd, now what do we do.. + pnd_box_handle h = pnd_disco_file ( app -> object_path, app -> object_filename ); + + if ( h ) { + pnd_disco_t *d = pnd_box_get_head ( h ); + iconbuf = pnd_emit_icon_to_buffer ( d, &buflen ); + } + + } // filename has .pnd? + + } else { // pull icon into buffer from .pnd if not already found an icon if ( ! iconbuf ) { diff --git a/minimenu/mmui.c b/minimenu/mmui.c index 6b80599..31ca915 100644 --- a/minimenu/mmui.c +++ b/minimenu/mmui.c @@ -1291,6 +1291,9 @@ void ui_process_input ( unsigned char block_p ) { } } else if ( sel == 9 ) { // about + char buffer [ PATH_MAX ]; + sprintf ( buffer, "%s/about.txt", g_skinpath ); + ui_aboutscreen ( buffer ); } ui_event++; @@ -2429,3 +2432,229 @@ unsigned char ui_pick_skin ( void ) { return ( 0 ); } + +void ui_aboutscreen ( char *textpath ) { +#define PIXELW 7 +#define PIXELH 7 +#define MARGINW 3 +#define MARGINH 3 +#define SCRW 800 +#define SCRH 480 +#define ROWS SCRH / ( PIXELH + MARGINH ) +#define COLS SCRW / ( PIXELW + MARGINW ) + + unsigned char pixelboard [ ROWS * COLS ]; // pixel heat + bzero ( pixelboard, ROWS * COLS ); + + SDL_Surface *rtext; + SDL_Rect r; + + SDL_Color rtextc = { 200, 200, 200, 100 }; + + // pixel scroller + char *textloop [ 500 ]; + unsigned int textmax = 0; + bzero ( textloop, 500 * sizeof(char*) ); + + // cursor scroller + char cbuffer [ 50000 ]; + bzero ( cbuffer, 50000 ); + unsigned int crevealed = 0; + + FILE *f = fopen ( textpath, "r" ); + + if ( ! f ) { + pnd_log ( pndn_error, "ERROR: Couldn't open about text: %s\n", textpath ); + return; + } + + char textbuf [ 100 ]; + while ( fgets ( textbuf, 100, f ) ) { + + // add to full buffer + strncat ( cbuffer, textbuf, 50000 ); + + // chomp + if ( strchr ( textbuf, '\n' ) ) { + * strchr ( textbuf, '\n' ) = '\0'; + } + + // add to pixel loop + if ( 1||textbuf [ 0 ] ) { + textloop [ textmax ] = strdup ( textbuf ); + textmax++; + } + + } // while fgets + + fclose ( f ); + + unsigned int textiter = 0; + while ( textiter < textmax ) { + char *text = textloop [ textiter ]; + + rtext = NULL; + if ( text [ 0 ] ) { + // render to surface + rtext = TTF_RenderText_Blended ( g_grid_font, text, rtextc ); + + // render font to pixelboard + unsigned int px, py; + unsigned char *ph; + unsigned int *pixels = rtext -> pixels; + unsigned char cr, cg, cb, ca; + for ( py = 0; py < rtext -> h; py ++ ) { + for ( px = 0; px < ( rtext -> w > COLS ? COLS : rtext -> w ); px++ ) { + + SDL_GetRGBA ( pixels [ ( py * rtext -> pitch / 4 ) + px ], + rtext -> format, &cr, &cg, &cb, &ca ); + + if ( ca != 0 ) { + + ph = pixelboard + ( /*y offset */ 30 * COLS ) + ( py * COLS ) + px /* / 2 */; + + if ( *ph < 100 ) { + *ph = 100; + } + + ca /= 5; + if ( *ph + ca < 250 ) { + *ph += ca; + } + + } // got a pixel? + + } // x + } // y + + } // got text? + + unsigned int runcount = 10; + while ( runcount-- ) { + + // clear display + SDL_FillRect( sdl_realscreen, NULL /* whole */, 0 ); + + // render pixelboard + unsigned int x, y; + unsigned int c; + for ( y = 0; y < ROWS; y++ ) { + for ( x = 0; x < COLS; x++ ) { + + if ( 1||pixelboard [ ( y * COLS ) + x ] ) { + + // position + r.x = x * ( PIXELW + MARGINW ); + r.y = y * ( PIXELH + MARGINH ); + r.w = PIXELW; + r.h = PIXELH; + // heat -> colour + c = SDL_MapRGB ( sdl_realscreen -> format, 100 /* r */, 0 /* g */, pixelboard [ ( y * COLS ) + x ] ); + // render + SDL_FillRect( sdl_realscreen, &r /* whole */, c ); + + } + + } // x + } // y + + // cool pixels + unsigned char *pc = pixelboard; + for ( y = 0; y < ROWS; y++ ) { + for ( x = 0; x < COLS; x++ ) { + + if ( *pc > 10 ) { + (*pc) -= 3; + } + + pc++; + } // x + } // y + + // slide pixels upwards + memmove ( pixelboard, pixelboard + COLS, ( COLS * ROWS ) - COLS ); + + // render actual readable text + { + + // display up to cursor + SDL_Rect dest; + unsigned int cdraw = 0; + SDL_Surface *cs; + char ctb [ 2 ]; + + if ( crevealed > 200 ) { + cdraw = crevealed - 200; + } + + dest.x = 400; + dest.y = 20; + + for ( ; cdraw < crevealed; cdraw++ ) { + ctb [ 0 ] = cbuffer [ cdraw ]; + ctb [ 1 ] = '\0'; + // move over or down + if ( cbuffer [ cdraw ] == '\n' ) { + // EOL + dest.x = 400; + dest.y += 14; + + if ( dest.y > 450 ) { + dest.y = 450; + } + + } else { + // draw the char + cs = TTF_RenderText_Blended ( g_tab_font, ctb, rtextc ); + if ( cs ) { + SDL_BlitSurface ( cs, NULL /* all */, sdl_realscreen, &dest ); + SDL_FreeSurface ( cs ); + // over + dest.x += cs -> w; + } + } + + } + + dest.w = 10; + dest.h = 20; + SDL_FillRect ( sdl_realscreen, &dest /* whole */, 220 ); + + // increment cursor to next character + if ( cbuffer [ crevealed ] != '\0' ) { + crevealed++; + } + + } // draw cursor text + + // reveal + // + SDL_UpdateRect ( sdl_realscreen, 0, 0, 0, 0 ); // whole screen + + usleep ( 50000 ); + + // any button? if so, about + { + SDL_PumpEvents(); + + SDL_Event e; + + if ( SDL_PeepEvents ( &e, 1, SDL_GETEVENT, SDL_EVENTMASK(SDL_KEYUP) ) > 0 ) { + return; + } + + } + + } // while cooling + + if ( rtext ) { + SDL_FreeSurface ( rtext ); + } + + textiter++; + } // while more text + + // free up + + return; +} diff --git a/minimenu/mmui.h b/minimenu/mmui.h index 6afb734..df6eb9b 100644 --- a/minimenu/mmui.h +++ b/minimenu/mmui.h @@ -71,6 +71,8 @@ void ui_discoverscreen ( unsigned char clearscreen ); // screen to show while sc void ui_cachescreen ( unsigned char clearscreen, char *filename ); // while caching icons, categories and preview-pics-Now-mode void ui_show_hourglass ( unsigned char updaterect ); void ui_post_scan ( void ); +unsigned char ui_show_info ( char *pndrun, pnd_disco_t *p ); +void ui_aboutscreen ( char *textpath ); /* internal functions follow */ @@ -97,7 +99,6 @@ void ui_push_rtrigger ( void ); unsigned char ui_determine_row ( mm_appref_t *a ); unsigned char ui_determine_screen_row ( mm_appref_t *a ); unsigned char ui_determine_screen_col ( mm_appref_t *a ); -unsigned char ui_show_info ( char *pndrun, pnd_disco_t *p ); // ui_render() can register tappable-areas which touchscreen code can then figure out if we made a hit void ui_register_reset ( void ); diff --git a/minimenu/skin/default/about.txt b/minimenu/skin/default/about.txt index 3ade66c..7830da3 100644 --- a/minimenu/skin/default/about.txt +++ b/minimenu/skin/default/about.txt @@ -1,14 +1,14 @@ Thanks to our patient wives and kids! -(I'm old school, not old) minimenu is for DaveC! +Greets out to.. EvilDragon Craigix mfk MWeston -Greetz to the unsung heroes! +and to the unsung heroes ;) DJWillis notaz diff --git a/minimenu/skin/perty/about.txt b/minimenu/skin/perty/about.txt index 3ade66c..7830da3 100644 --- a/minimenu/skin/perty/about.txt +++ b/minimenu/skin/perty/about.txt @@ -1,14 +1,14 @@ Thanks to our patient wives and kids! -(I'm old school, not old) minimenu is for DaveC! +Greets out to.. EvilDragon Craigix mfk MWeston -Greetz to the unsung heroes! +and to the unsung heroes ;) DJWillis notaz