/** * Make a screenshot of the map. * @param t Screenshot type: World or viewport screenshot * @return true on success */ static bool MakeLargeWorldScreenshot(ScreenshotType t) { ViewPort vp; SetupScreenshotViewport(t, &vp); const ScreenshotFormat *sf = _screenshot_formats + _cur_screenshot_format; return sf->proc(MakeScreenshotName(SCREENSHOT_NAME, sf->extension), LargeWorldCallback, &vp, vp.width, vp.height, BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth(), _cur_palette.palette); }
/** * Make an actual screenshot. * @param t the type of screenshot to make. * @param name the name to give to the screenshot. * @return true iff the screenshot was made successfully */ bool MakeScreenshot(ScreenshotType t, const char *name) { if (t == SC_VIEWPORT) { /* First draw the dirty parts of the screen and only then change the name * of the screenshot. This way the screenshot will always show the name * of the previous screenshot in the 'successful' message instead of the * name of the new screenshot (or an empty name). */ UndrawMouseCursor(); DrawDirtyBlocks(); } _screenshot_name[0] = '\0'; if (name != NULL) strecpy(_screenshot_name, name, lastof(_screenshot_name)); bool ret; switch (t) { case SC_VIEWPORT: ret = MakeSmallScreenshot(false); break; case SC_CRASHLOG: ret = MakeSmallScreenshot(true); break; case SC_ZOOMEDIN: case SC_DEFAULTZOOM: case SC_WORLD: ret = MakeLargeWorldScreenshot(t); break; case SC_HEIGHTMAP: { const ScreenshotFormat *sf = _screenshot_formats + _cur_screenshot_format; ret = MakeHeightmapScreenshot(MakeScreenshotName(HEIGHTMAP_NAME, sf->extension)); break; } default: NOT_REACHED(); } if (ret) { SetDParamStr(0, _screenshot_name); ShowErrorMessage(STR_MESSAGE_SCREENSHOT_SUCCESSFULLY, INVALID_STRING_ID, WL_WARNING); } else { ShowErrorMessage(STR_ERROR_SCREENSHOT_FAILED, INVALID_STRING_ID, WL_ERROR); } return ret; }
static bool MakeWorldScreenshot() { ViewPort vp; const ScreenshotFormat *sf; vp.zoom = ZOOM_LVL_WORLD_SCREENSHOT; vp.left = 0; vp.top = 0; vp.virtual_left = -(int)MapMaxX() * TILE_PIXELS; vp.virtual_top = 0; vp.virtual_width = (MapMaxX() + MapMaxY()) * TILE_PIXELS; vp.width = vp.virtual_width; vp.virtual_height = (MapMaxX() + MapMaxY()) * TILE_PIXELS >> 1; vp.height = vp.virtual_height; sf = _screenshot_formats + _cur_screenshot_format; return sf->proc(MakeScreenshotName(sf->extension), LargeWorldCallback, &vp, vp.width, vp.height, BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth(), _cur_palette); }
/** Make a zoomed-in screenshot of the currently visible area. */ static bool MakeZoomedInScreenshot() { Window *w = FindWindowById(WC_MAIN_WINDOW, 0); ViewPort vp; vp.zoom = _settings_client.gui.zoom_min; vp.left = w->viewport->left; vp.top = w->viewport->top; vp.virtual_left = w->viewport->virtual_left; vp.virtual_top = w->viewport->virtual_top; vp.virtual_width = w->viewport->virtual_width; vp.width = UnScaleByZoom(vp.virtual_width, vp.zoom); vp.virtual_height = w->viewport->virtual_height; vp.height = UnScaleByZoom(vp.virtual_height, vp.zoom); const ScreenshotFormat *sf = _screenshot_formats + _cur_screenshot_format; return sf->proc(MakeScreenshotName(SCREENSHOT_NAME, sf->extension), LargeWorldCallback, &vp, vp.width, vp.height, BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth(), _cur_palette.palette); }
/** Make a screenshot of the whole map. */ static bool MakeWorldScreenshot() { ViewPort vp; const ScreenshotFormat *sf; /* We need to account for a hill or high building at tile 0,0. */ int extra_height_top = TilePixelHeight(0) + 150; /* If there is a hill at the bottom don't create a large black area. */ int reclaim_height_bottom = TilePixelHeight(MapSize() - 1); vp.zoom = ZOOM_LVL_WORLD_SCREENSHOT; vp.left = 0; vp.top = 0; vp.virtual_left = -(int)MapMaxX() * TILE_PIXELS * ZOOM_LVL_BASE; vp.virtual_top = -extra_height_top * ZOOM_LVL_BASE; vp.virtual_width = (MapMaxX() + MapMaxY()) * TILE_PIXELS; vp.width = vp.virtual_width; vp.virtual_height = ((MapMaxX() + MapMaxY()) * TILE_PIXELS >> 1) + extra_height_top - reclaim_height_bottom; vp.height = vp.virtual_height; sf = _screenshot_formats + _cur_screenshot_format; return sf->proc(MakeScreenshotName(SCREENSHOT_NAME, sf->extension), LargeWorldCallback, &vp, vp.width, vp.height, BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth(), _cur_palette.palette); }
/** Make a screenshot of the current screen. */ static bool MakeSmallScreenshot(bool crashlog) { const ScreenshotFormat *sf = _screenshot_formats + _cur_screenshot_format; return sf->proc(MakeScreenshotName(SCREENSHOT_NAME, sf->extension, crashlog), CurrentScreenCallback, NULL, _screen.width, _screen.height, BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth(), _cur_palette.palette); }