void DrawSaveStates(SDL_Surface *screen, double exs, double eys, int rs, int gs, int bs, int as) { if(StateShow < MDFND_GetTime()) { SSCleanup(); } if(StateStatus) { if(!PreviewSurface) { PreviewSurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA, StateStatus->w + 2, StateStatus->h + 2, 32, 0xFF << rs, 0xFF << gs, 0xFF << bs, 0xFF << as); if(!PreviewSurface) { printf("Iyee: %d %d\n", StateStatus->w, StateStatus->h); return; } PreviewRect.x = PreviewRect.y = 0; PreviewRect.w = StateStatus->w + 2; PreviewRect.h = StateStatus->h + 2; MDFN_DrawRectangleAlpha((uint32*)PreviewSurface->pixels, PreviewSurface->pitch >> 2, 0, 0, MK_COLOR_A(PreviewSurface, 0x00, 0x00, 0x9F, 0xFF), MK_COLOR_A(PreviewSurface, 0x00, 0x00, 0x00, 0x80), StateStatus->w + 2, StateStatus->h + 2); uint32 *psp = (uint32*)PreviewSurface->pixels; psp += PreviewSurface->pitch >> 2; psp++; if(StateStatus->gfx) { for(uint32 y = 0; y < StateStatus->h; y++) { uint8 *src_row = StateStatus->gfx + y * StateStatus->w * 3; for(uint32 x = 0; x < StateStatus->w; x++) { psp[x] = MK_COLOR_A(PreviewSurface, src_row[0], src_row[1], src_row[2], 0xFF); src_row += 3; } psp += PreviewSurface->pitch >> 2; } } if(!TextSurface) { TextSurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA, 230, 40, 32, 0xFF << rs, 0xFF << gs, 0xFF << bs, 0xFF << as); SDL_SetColorKey(TextSurface, SDL_SRCCOLORKEY, 0); SDL_SetAlpha(TextSurface, SDL_SRCALPHA, 0); TextRect.x = TextRect.y = 0; TextRect.w = 230; TextRect.h = 40; } if(IsMovie) { UTF8 text[256]; if(StateStatus->current_movie > 0) trio_snprintf((char *)text, 256, _("-recording movie %d-"), StateStatus->current_movie-1); else if (StateStatus->current_movie < 0) trio_snprintf((char *)text, 256, _("-playing movie %d-"),-1 - StateStatus->current_movie); else trio_snprintf((char *)text, 256, _("-select movie-")); DrawStateMovieRow(TextSurface, StateStatus->status, StateStatus->current, StateStatus->recently_saved, text); } else DrawStateMovieRow(TextSurface, StateStatus->status, StateStatus->current, StateStatus->recently_saved, (UTF8 *)_("-select state-")); } } // end if(StateStatus)
void DrawSaveStates(SDL_Surface *screen, double exs, double eys, int rs, int gs, int bs, int as) { StateStatusStruct *tmps; if(StateShow < MDFND_GetTime()) { if(PreviewSurface) { SDL_FreeSurface(PreviewSurface); PreviewSurface = NULL; } if(StateStatus) { if(StateStatus->gfx) free(StateStatus->gfx); free(StateStatus); StateStatus = NULL; } } if(MovieShow < MDFND_GetTime()) { if(PreviewSurface) { SDL_FreeSurface(PreviewSurface); PreviewSurface = NULL; } if(MovieStatus) { if(MovieStatus->gfx) free(MovieStatus->gfx); free(MovieStatus); MovieStatus = NULL; } } tmps = MovieStatus; if(StateStatus) tmps = StateStatus; if(tmps) { if(PreviewSurface) { SDL_FreeSurface(PreviewSurface); PreviewSurface = NULL; } PreviewSurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA, tmps->w + 2, tmps->h + 2, 32, 0xFF << rs, 0xFF << gs, 0xFF << bs, 0xFF << as); PreviewRect.x = PreviewRect.y = 0; PreviewRect.w = tmps->w + 2; PreviewRect.h = tmps->h + 2; MDFN_DrawRectangleAlpha((uint32*)PreviewSurface->pixels, PreviewSurface->pitch >> 2, 0, 0, MK_COLOR_A(PreviewSurface, 0x00, 0x00, 0x9F, 0xFF), tmps->w + 2, tmps->h + 2); uint32 *psp = (uint32*)PreviewSurface->pixels; psp += PreviewSurface->pitch >> 2; psp++; if(tmps->gfx) for(int y = 0; y < tmps->h; y++) { memcpy(psp, tmps->gfx + y * tmps->pitch, tmps->w * sizeof(uint32)); psp += PreviewSurface->pitch >> 2; } if(!TextSurface) { TextSurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA, 230, 40, 32, 0xFF << rs, 0xFF << gs, 0xFF << bs, 0xFF << as); SDL_SetColorKey(TextSurface, SDL_SRCCOLORKEY, 0); SDL_SetAlpha(TextSurface, SDL_SRCALPHA, 0); TextRect.x = TextRect.y = 0; TextRect.w = 230; TextRect.h = 40; } if(tmps == MovieStatus) { UTF8 text[256]; if(tmps->current_movie > 0) trio_snprintf((char *)text, 256, _("-recording movie %d-"), tmps->current_movie-1); else if (tmps->current_movie < 0) trio_snprintf((char *)text, 256, _("-playing movie %d-"),-1 - tmps->current_movie); else trio_snprintf((char *)text, 256, _("-select movie-")); DrawStateMovieRow(TextSurface, tmps->status, tmps->current, tmps->recently_saved, text); } else DrawStateMovieRow(TextSurface, tmps->status, tmps->current, tmps->recently_saved, (UTF8 *)_("-select state-")); } if(PreviewSurface) { SDL_Rect tdrect, drect; int meow = ((screen->w / CurGame->width) + 1) / 2; if(!meow) meow = 1; tdrect.w = TextRect.w * meow; tdrect.h = TextRect.h * meow; tdrect.x = (screen->w - tdrect.w) / 2; tdrect.y = screen->h - tdrect.h; BlitRaw(TextSurface, &TextRect, &tdrect); drect.w = PreviewRect.w * meow; drect.h = PreviewRect.h * meow; drect.x = (screen->w - drect.w) / 2; drect.y = screen->h - drect.h - tdrect.h - 4; BlitRaw(PreviewSurface, &PreviewRect, &drect); } }