/* updates only what needs changing (time_elapsed==NONE means redraw everything no matter what, but skip the interface frame) */ void update_interface( short time_elapsed) { if (!game_window_is_full_screen()) { _set_port_to_screen_window(); update_everything(time_elapsed); _restore_port(); } return; }
static bool build_map_preview(std::ostringstream& ostream) { SDL_Rect r = {0, 0, RENDER_WIDTH, RENDER_HEIGHT}; SDL_Surface *surface = SDL_CreateRGBSurface(SDL_SWSURFACE, r.w, r.h, 32, 0xff0000, 0x00ff00, 0x0000ff, 0); if (!surface) return false; SDL_FillRect(surface, &r, SDL_MapRGB(surface->format, 0, 0, 0)); struct overhead_map_data overhead_data; overhead_data.half_width = r.w >> 1; overhead_data.half_height = r.h >> 1; overhead_data.width = r.w; overhead_data.height = r.h; overhead_data.top = overhead_data.left = 0; overhead_data.scale = RENDER_SCALE; overhead_data.mode = _rendering_saved_game_preview; overhead_data.origin.x = local_player->location.x; overhead_data.origin.y = local_player->location.y; bool old_OGL_MapActive = OGL_MapActive; _set_port_to_custom(surface); OGL_MapActive = false; _render_overhead_map(&overhead_data); OGL_MapActive = old_OGL_MapActive; _restore_port(); SDL_RWops *rwops = SDL_RWFromOStream(ostream); #if defined(HAVE_PNG) && defined(HAVE_SDL_IMAGE_H) int ret = IMG_SavePNG_RW(rwops, surface, IMG_COMPRESS_DEFAULT, NULL, 0); #else int ret = SDL_SaveBMP_RW(surface, rwops, false); #endif SDL_FreeSurface(surface); SDL_RWclose(rwops); return (ret == 0); }