OpenTTD Source 20250312-master-gcdcc6b491d
|
The creation of screenshots! More...
#include "stdafx.h"
#include "core/backup_type.hpp"
#include "fileio_func.h"
#include "viewport_func.h"
#include "gfx_func.h"
#include "screenshot.h"
#include "screenshot_gui.h"
#include "blitter/factory.hpp"
#include "zoom_func.h"
#include "saveload/saveload.h"
#include "company_func.h"
#include "strings_func.h"
#include "error.h"
#include "textbuf_gui.h"
#include "window_gui.h"
#include "window_func.h"
#include "tile_map.h"
#include "landscape.h"
#include "video/video_driver.hpp"
#include "smallmap_gui.h"
#include "screenshot_type.h"
#include "table/strings.h"
#include "safeguards.h"
Go to the source code of this file.
Functions | |
static ScreenshotProvider * | GetScreenshotProvider () |
Get the screenshot provider for the selected format. | |
std::string_view | GetCurrentScreenshotExtension () |
Get filename extension of current screenshot file format. | |
static void | CurrentScreenCallback (void *, void *buf, uint y, uint pitch, uint n) |
Callback of the screenshot generator that dumps the current video buffer. | |
static void | LargeWorldCallback (void *userdata, void *buf, uint y, uint pitch, uint n) |
generate a large piece of the world | |
static const char * | MakeScreenshotName (std::string_view default_fn, std::string_view ext, bool crashlog=false) |
Construct a pathname for a screenshot file. | |
static bool | MakeSmallScreenshot (bool crashlog) |
Make a screenshot of the current screen. | |
void | SetupScreenshotViewport (ScreenshotType t, Viewport *vp, uint32_t width, uint32_t height) |
Configure a Viewport for rendering (a part of) the map into a screenshot. | |
static bool | MakeLargeWorldScreenshot (ScreenshotType t, uint32_t width=0, uint32_t height=0) |
Make a screenshot of the map. | |
static void | HeightmapCallback (void *, void *buffer, uint y, uint, uint n) |
Callback for generating a heightmap. | |
bool | MakeHeightmapScreenshot (const char *filename) |
Make a heightmap of the current map. | |
static void | ScreenshotConfirmationCallback (Window *, bool confirmed) |
Callback on the confirmation window for huge screenshots. | |
void | MakeScreenshotWithConfirm (ScreenshotType t) |
Make a screenshot. | |
static bool | RealMakeScreenshot (ScreenshotType t, std::string name, uint32_t width, uint32_t height) |
Make a screenshot. | |
bool | MakeScreenshot (ScreenshotType t, std::string name, uint32_t width, uint32_t height) |
Schedule making a screenshot. | |
static void | MinimapScreenCallback (void *, void *buf, uint y, uint pitch, uint n) |
bool | MakeMinimapWorldScreenshot () |
Make a minimap screenshot. | |
Variables | |
static const char *const | SCREENSHOT_NAME = "screenshot" |
Default filename of a saved screenshot. | |
static const char *const | HEIGHTMAP_NAME = "heightmap" |
Default filename of a saved heightmap. | |
std::string | _screenshot_format_name |
Extension of the current screenshot format. | |
static std::string | _screenshot_name |
Filename of the screenshot file. | |
std::string | _full_screenshot_path |
Pathname of the screenshot file. | |
uint | _heightmap_highest_peak |
When saving a heightmap, this contains the highest peak on the map. | |
static ScreenshotType | _confirmed_screenshot_type |
Screenshot type the current query is about to confirm. | |
The creation of screenshots!
Definition in file screenshot.cpp.
|
static |
Callback of the screenshot generator that dumps the current video buffer.
Definition at line 73 of file screenshot.cpp.
References Blitter::CopyImageToBuffer(), BlitterFactory::GetCurrentBlitter(), and Blitter::MoveTo().
Referenced by MakeSmallScreenshot().
std::string_view GetCurrentScreenshotExtension | ( | ) |
Get filename extension of current screenshot file format.
Definition at line 61 of file screenshot.cpp.
References GetScreenshotProvider().
Referenced by FiosMakeHeightmapName().
|
static |
Get the screenshot provider for the selected format.
If the selected provider is not found, then the first provider will be used instead.
Definition at line 49 of file screenshot.cpp.
References _screenshot_format_name, and ProviderManager< TProviderType >::GetProviders().
Referenced by GetCurrentScreenshotExtension(), MakeHeightmapScreenshot(), MakeLargeWorldScreenshot(), MakeMinimapWorldScreenshot(), MakeSmallScreenshot(), and RealMakeScreenshot().
|
static |
Callback for generating a heightmap.
Supports 8bpp grayscale only.
buffer | Destination buffer. |
y | Line number of the first line to write. |
n | Number of lines to write. |
Definition at line 294 of file screenshot.cpp.
References _heightmap_highest_peak, Map::MaxX(), TileAddXY(), TileHeight(), and TileXY().
Referenced by MakeHeightmapScreenshot().
|
static |
generate a large piece of the world
userdata | Viewport area to draw |
buf | Videobuffer with same bitdepth as current blitter |
y | First line to render |
pitch | Pitch of the videobuffer |
n | Number of lines to render |
Definition at line 88 of file screenshot.cpp.
References _screen_disable_anim, Viewport::left, ScaleByZoom(), Viewport::top, Viewport::virtual_left, Viewport::virtual_top, Viewport::width, Viewport::zoom, and ZOOM_LVL_WORLD_SCREENSHOT.
Referenced by MakeLargeWorldScreenshot().
bool MakeHeightmapScreenshot | ( | const char * | filename | ) |
Make a heightmap of the current map.
filename | Filename to use for saving. |
Definition at line 314 of file screenshot.cpp.
References _heightmap_highest_peak, GetScreenshotProvider(), HeightmapCallback(), Map::Iterate(), lengthof, Map::SizeX(), Map::SizeY(), and TileHeight().
Referenced by RealMakeScreenshot().
|
static |
Make a screenshot of the map.
t | Screenshot type: World or viewport screenshot |
width | the width of the screenshot of, or 0 for current viewport width. |
height | the height of the screenshot of, or 0 for current viewport height. |
Definition at line 275 of file screenshot.cpp.
References _cur_palette, BlitterFactory::GetCurrentBlitter(), Blitter::GetScreenDepth(), GetScreenshotProvider(), Viewport::height, LargeWorldCallback(), MakeScreenshotName(), Palette::palette, SCREENSHOT_NAME, SetupScreenshotViewport(), and Viewport::width.
Referenced by RealMakeScreenshot().
bool MakeMinimapWorldScreenshot | ( | ) |
Make a minimap screenshot.
Definition at line 498 of file screenshot.cpp.
References _cur_palette, GetScreenshotProvider(), MakeScreenshotName(), Palette::palette, SCREENSHOT_NAME, Map::SizeX(), and Map::SizeY().
Referenced by RealMakeScreenshot().
bool MakeScreenshot | ( | ScreenshotType | t, |
std::string | name, | ||
uint32_t | width, | ||
uint32_t | height | ||
) |
Schedule making a screenshot.
Unconditionally take a screenshot of the requested type.
t | the type of screenshot to make. |
name | the name to give to the screenshot. |
width | the width of the screenshot of, or 0 for current viewport width (only works for SC_ZOOMEDIN and SC_DEFAULTZOOM). |
height | the height of the screenshot of, or 0 for current viewport height (only works for SC_ZOOMEDIN and SC_DEFAULTZOOM). |
Definition at line 457 of file screenshot.cpp.
References VideoDriver::GetInstance(), lock, VideoDriver::QueueOnMainThread(), RealMakeScreenshot(), and SC_CRASHLOG.
Referenced by MakeScreenshotWithConfirm(), ScreenshotConfirmationCallback(), and CrashLog::WriteScreenshot().
|
static |
Construct a pathname for a screenshot file.
default_fn | Default filename. |
ext | Extension to use. |
crashlog | Create path for crash.png |
Definition at line 140 of file screenshot.cpp.
References _full_screenshot_path, _local_company, _personal_dir, _screenshot_name, COMPANY_SPECTATOR, FileExists(), FiosGetScreenshotDir(), and GenerateDefaultSaveName().
Referenced by MakeLargeWorldScreenshot(), MakeMinimapWorldScreenshot(), MakeSmallScreenshot(), and RealMakeScreenshot().
void MakeScreenshotWithConfirm | ( | ScreenshotType | t | ) |
Make a screenshot.
Ask for confirmation first if the screenshot will be huge.
t | Screenshot type: World, defaultzoom, heightmap or viewport screenshot |
Definition at line 353 of file screenshot.cpp.
References _confirmed_screenshot_type, GetEncodedString(), Viewport::height, MakeScreenshot(), SC_HEIGHTMAP, SC_MINIMAP, ScreenshotConfirmationCallback(), SetupScreenshotViewport(), ShowQuery(), Map::SizeX(), Map::SizeY(), and Viewport::width.
Referenced by ScreenshotWindow::OnClick(), MainToolbarWindow::OnHotkey(), and ScenarioEditorToolbarWindow::OnHotkey().
|
static |
Make a screenshot of the current screen.
Definition at line 178 of file screenshot.cpp.
References _cur_palette, CurrentScreenCallback(), BlitterFactory::GetCurrentBlitter(), Blitter::GetScreenDepth(), GetScreenshotProvider(), MakeScreenshotName(), Palette::palette, and SCREENSHOT_NAME.
Referenced by RealMakeScreenshot().
|
static |
Definition at line 474 of file screenshot.cpp.
|
static |
Make a screenshot.
t | the type of screenshot to make. |
name | the name to give to the screenshot. |
width | the width of the screenshot of, or 0 for current viewport width (only works for SC_ZOOMEDIN and SC_DEFAULTZOOM). |
height | the height of the screenshot of, or 0 for current viewport height (only works for SC_ZOOMEDIN and SC_DEFAULTZOOM). |
Definition at line 382 of file screenshot.cpp.
References _heightmap_highest_peak, _screenshot_name, DrawDirtyBlocks(), GetEncodedString(), GetScreenshotProvider(), HEIGHTMAP_NAME, MakeHeightmapScreenshot(), MakeLargeWorldScreenshot(), MakeMinimapWorldScreenshot(), MakeScreenshotName(), MakeSmallScreenshot(), SC_CRASHLOG, SC_DEFAULTZOOM, SC_HEIGHTMAP, SC_MINIMAP, SC_VIEWPORT, SC_WORLD, SC_ZOOMEDIN, SetScreenshotWindowVisibility(), ShowErrorMessage(), WL_ERROR, and WL_WARNING.
Referenced by MakeScreenshot().
|
static |
Callback on the confirmation window for huge screenshots.
confirmed | true on confirmation |
Definition at line 342 of file screenshot.cpp.
References _confirmed_screenshot_type, and MakeScreenshot().
Referenced by MakeScreenshotWithConfirm().
void SetupScreenshotViewport | ( | ScreenshotType | t, |
Viewport * | vp, | ||
uint32_t | width, | ||
uint32_t | height | ||
) |
Configure a Viewport for rendering (a part of) the map into a screenshot.
t | Screenshot type | |
width | the width of the screenshot, or 0 for current viewport width (needs to be 0 with SC_VIEWPORT, SC_CRASHLOG, and SC_WORLD). | |
height | the height of the screenshot, or 0 for current viewport height (needs to be 0 with SC_VIEWPORT, SC_CRASHLOG, and SC_WORLD). | |
[out] | vp | Result viewport |
Definition at line 194 of file screenshot.cpp.
References _settings_client, _settings_game, GameSettings::construction, ConstructionSettings::freeform_edges, GetMainWindow(), ClientSettings::gui, Viewport::height, Viewport::left, RemapCoords(), SC_CRASHLOG, SC_VIEWPORT, SC_WORLD, SC_ZOOMEDIN, Map::Size(), TILE_SIZE, TilePixelHeight(), TileX(), TileXY(), TileY(), Viewport::top, UnScaleByZoom(), Window::viewport, Viewport::virtual_height, Viewport::virtual_left, Viewport::virtual_top, Viewport::virtual_width, Viewport::width, Viewport::zoom, ZOOM_LVL_VIEWPORT, ZOOM_LVL_WORLD_SCREENSHOT, and GUISettings::zoom_min.
Referenced by MakeLargeWorldScreenshot(), and MakeScreenshotWithConfirm().
|
static |
Screenshot type the current query is about to confirm.
Definition at line 336 of file screenshot.cpp.
Referenced by MakeScreenshotWithConfirm(), and ScreenshotConfirmationCallback().
std::string _full_screenshot_path |
Pathname of the screenshot file.
Definition at line 41 of file screenshot.cpp.
Referenced by MakeScreenshotName(), and CrashLog::WriteScreenshot().
uint _heightmap_highest_peak |
When saving a heightmap, this contains the highest peak on the map.
Definition at line 42 of file screenshot.cpp.
Referenced by HeightmapCallback(), MakeHeightmapScreenshot(), and RealMakeScreenshot().
std::string _screenshot_format_name |
Extension of the current screenshot format.
Definition at line 39 of file screenshot.cpp.
Referenced by GetScreenshotProvider().
|
static |
Filename of the screenshot file.
Definition at line 40 of file screenshot.cpp.
Referenced by MakeScreenshotName(), and RealMakeScreenshot().
|
static |
Default filename of a saved heightmap.
Definition at line 37 of file screenshot.cpp.
Referenced by RealMakeScreenshot().
|
static |
Default filename of a saved screenshot.
Definition at line 36 of file screenshot.cpp.
Referenced by MakeLargeWorldScreenshot(), MakeMinimapWorldScreenshot(), and MakeSmallScreenshot().