void gfx_draw_outro(SDL_Surface * screen) { SDL_Surface *logo = NULL; int stime = 0, alpha = 0, time_var = 0; SDL_Surface *black = gfx_new_surface(320, 240, 1); if (!black) { if (black) SDL_FreeSurface(black); return; } logo = gfx_load_image("images/icons/game_run.png", 0); stime = SDL_GetTicks(); time_var = SDL_GetTicks(); while (stime + 200 > SDL_GetTicks()) { SDL_FillRect(black, NULL, SDL_MapRGBA(black->format, 0, 0, 0, alpha)); bg_draw(screen); gfx_draw_image(black, 0, 0, screen); SDL_Flip(screen); alpha += (255 / (float) 200) * (SDL_GetTicks() - time_var); if (alpha > 255) alpha = 255; time_var = SDL_GetTicks(); } sfx_play(SFXRUN); alpha = 255; while (stime + 3000 > SDL_GetTicks()) { SDL_FillRect(black, NULL, SDL_MapRGBA(black->format, 0, 0, 0, alpha)); gfx_draw_image(black, 0, 0, screen); if (logo) gfx_draw_image(logo, (screen->w - logo->w) / 2, (screen->h - logo->h) / 2, screen); SDL_Flip(screen); } SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0)); SDL_Flip(screen); SDL_FreeSurface(logo); }
int main( int argc, char *arvg[] ) { int quit = 0; int config_status = 0; int event; #ifdef __WIN32__ freopen( "cabrio.out", "w", stdout ); freopen( "cabrio.err", "w", stderr ); #endif config_status = config_open( NULL ); if( config_status == -1 ) return -1; if( sdl_init() != 0 ) bail(); if( ogl_init() != 0 ) bail(); /* Clear the screen as soon as we can. This avoids graphics * glitches which can occur with some SDL implementations. */ ogl_clear(); sdl_swap(); if( event_init() != 0 ) bail(); if( font_init() != 0 ) bail(); if( config_status == 1 ) { /* Config file didn't exist, so run the setup utility */ if( setup() != 0 ) return -1; config_update(); if( config_create() != 0 ) return -1; } location_init(); /* If config or location results in a new font, it'll be loaded here. */ font_free(); font_init(); /* Large game lists take a while to initialise, * so show the background while we wait... */ bg_init(); bg_clear(); bg_draw(); sdl_swap(); if( platform_init() != 0 ) bail(); if( category_init() != 0 ) bail(); if( game_sel_init() != 0 ) bail(); if( hint_init() != 0 ) bail(); if( snap_init() != 0 ) bail(); if( game_list_create() != 0 ) bail(); if( menu_init() != 0 ) bail(); if( submenu_init() != 0 ) bail(); sound_init(); video_init(); event_flush(); if( !config_get()->iface.theme.menu.auto_hide ) menu_show(); focus_set( FOCUS_GAMESEL ); while( !quit ) { ogl_clear(); bg_draw(); snap_draw(); if (!config_get()->iface.hide_buttons) hint_draw(); menu_draw(); submenu_draw(); game_sel_draw(); sdl_swap(); if (Mix_PlayingMusic() != 1 && config_get()->iface.theme_sound && reader_running == 0) playmusic(); if (( event = event_poll() )) { if( supress_wait == 0 ) { if( event == EVENT_QUIT ) { quit = 1; } else { supress(); event_process( event ); } } } if( supress_wait > 0 ) supress_wait--; sdl_frame_delay(); } clean_up(); return 0; }
void sub_shc_handle_input(unsigned int button) { switch (button) { case GP2X_BUTTON_B: { sfx_play(SFXBACK); if(shc_showpopup) { POPUP_empty(); xmb_deactivateFlag(XMB_NOBATT | XMB_FOCUS); shc_showpopup = 0; } else { shc_init_stage = 10; shc_timer = 0; } break; } case GP2X_BUTTON_LEFT: { if(shc_showpopup) break; sfx_play(SFXBACK); shc_init_stage = 10; shc_timer = 0; break; } case GP2X_BUTTON_UP: { if(shc_showpopup) { if(POPUP_up()) sfx_play(SFXMOVE); break; } if (shc_selection > 0) { shc_movereq += 1; shc_selection--; } break; } case GP2X_BUTTON_DOWN: { if(shc_showpopup) { if(POPUP_down()) sfx_play(SFXMOVE); break; } if (shc_selection + 1 < shc_menucount) { shc_movereq -= 1; shc_selection++; } break; } case GP2X_BUTTON_Y: { shc_node *curr = shc_root; unsigned int i = 0; for (i = 0; curr != NULL && i < shc_selection; curr = curr->next, i++); if (!shc_init_stage && curr && !shc_showpopup) { struct stat statbuf; stat(curr->path, &statbuf); if (S_ISREG(statbuf.st_mode)) { xmb_activateFlag(XMB_NOBATT | XMB_FOCUS); POPUP_setrevert(NULL, 0); POPUP_add(NULL, "Delete Shortcut", sub_shc_popexec, 0); POPUP_setselected(0); shc_showpopup = 1; } } break; } case GP2X_BUTTON_X: { shc_node *curr = shc_root; unsigned int i = 0; if (shc_showpopup) { POPUP_execsel(); sub_shc_destroy(); /* Empty list */ sub_shc_init(shc_self); /* Reload */ xmb_deactivateFlag(XMB_NOBATT | XMB_FOCUS); POPUP_empty(); shc_showpopup = 0; break; } for (i = 0; curr != NULL && i < shc_selection; curr = curr->next, i++); if (curr) { char *dir_name = (char *) calloc(1, 1024); if (config_lookup_bool(&CONFIG, "outro")) gfx_draw_outro(SDL_GetVideoSurface()); gp2xmb_deinit(); if (dir_name) { strncpy(dir_name, curr->path, 1023); chdir(dirname(dir_name)); free(dir_name); } gp2x_setclock(200); if (execl(curr->path, curr->path, NULL)) { gp2xmb_init(); /* start everything up again */ while (!xmb_getFlagState(XMB_LOADED)) { bg_draw(SDL_GetVideoSurface()); progress_draw(SDL_GetVideoSurface(), 1); SDL_Flip(SDL_GetVideoSurface()); } msgbox(SDL_GetVideoSurface(),NULL, "System Error", "Failed to execute program.", OK); msgbox_retval(); return; } } break; } default: break; } }