32#include "table/strings.h"
52 if (providers.empty())
return nullptr;
54 auto it = std::ranges::find_if(providers, [](
const auto &p) {
return p->GetName() ==
_screenshot_format_name; });
55 if (it != std::end(providers))
return *it;
57 return providers.front();
64 if (provider ==
nullptr)
return {};
66 return provider->GetName();
76 void *src = blitter->
MoveTo(_screen.dst_ptr, 0, y);
93 .top =
static_cast<int>(y),
95 .height =
static_cast<int>(n),
96 .pitch =
static_cast<int>(pitch),
105 .width =
static_cast<int>(pitch),
106 .height =
static_cast<int>(n),
107 .pitch =
static_cast<int>(pitch),
115 while (vp.
width - left != 0) {
116 int wx = std::min(vp.
width - left, 1600);
135static std::string_view
MakeScreenshotName(std::string_view default_fn, std::string_view ext,
bool crashlog =
false)
159 for (uint serial = 1;; serial++) {
162 if (!generate)
break;
135static std::string_view
MakeScreenshotName(std::string_view default_fn, std::string_view ext,
bool crashlog =
false) {
…}
176 if (provider ==
nullptr)
return false;
196 assert(width == 0 && height == 0);
199 vp.virtual_left = w->
viewport->virtual_left;
200 vp.virtual_top = w->
viewport->virtual_top;
201 vp.virtual_width = w->
viewport->virtual_width;
202 vp.virtual_height = w->
viewport->virtual_height;
207 vp.width = _screen.width;
208 vp.height = _screen.height;
213 assert(width == 0 && height == 0);
236 vp.overlay =
nullptr;
243 vp.virtual_left = w->
viewport->virtual_left;
244 vp.virtual_top = w->
viewport->virtual_top;
246 if (width == 0 || height == 0) {
247 vp.virtual_width = w->
viewport->virtual_width;
248 vp.virtual_height = w->
viewport->virtual_height;
259 vp.overlay =
nullptr;
277 if (provider ==
nullptr)
return false;
282 [&](
void *buf, uint y, uint pitch, uint n) {
283 LargeWorldCallback(vp, buf, y, pitch, n);
296 uint8_t *buf = (uint8_t *)buffer;
317 if (provider ==
nullptr)
return false;
320 for (uint i = 0; i <
lengthof(palette); i++) {
361 if (width * height > 8192 * 8192) {
417 if (provider ==
nullptr) {
473static void MinimapScreenCallback(
void *buf, uint y, uint pitch, uint n)
475 uint32_t *ubuf = (uint32_t *)buf;
476 uint num = (pitch * n);
477 for (uint i = 0; i < num; i++) {
478 uint row = y + (int)(i / pitch);
484 uint32_t colour_buf = 0;
500 if (provider ==
nullptr)
return false;
Class for backupping variables and making sure they are restored later.
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
How all blitters should look like.
virtual void * MoveTo(void *video, int x, int y)=0
Move the destination pointer the requested amount x and y, keeping in mind any pitch and bpp of the r...
virtual uint8_t GetScreenDepth()=0
Get the screen depth this blitter works for.
virtual void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch)=0
Copy from the screen to a buffer in a palette format for 8bpp and RGBA format for 32bpp.
static std::vector< TProviderType * > & GetProviders()
Get the currently known sound loaders.
Base interface for a SoundLoader implementation.
void QueueOnMainThread(std::function< void()> &&func)
Queue a function to be called on the main thread with game state lock held and video buffer locked.
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Functions related to companies.
static constexpr CompanyID COMPANY_SPECTATOR
The client is spectating.
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23)
Functions related to errors.
@ WL_WARNING
Other information.
@ WL_ERROR
Errors (eg. saving/loading failed)
void ShowErrorMessage(EncodedString &&summary_msg, int x, int y, CommandCost &cc)
Display an error message in a window.
Factory to 'query' all available blitters.
std::string _personal_dir
custom directory for personal settings, saves, newgrf, etc.
bool FileExists(std::string_view filename)
Test whether the given filename exists.
Functions for Standard In/Out file operations.
std::string_view FiosGetScreenshotDir()
Get the directory for screenshots.
bool _screen_disable_anim
Disable palette animation (important for 32bpp-anim blitter during giant screenshot)
Functions related to the gfx engine.
Palette _cur_palette
Current palette.
void DrawDirtyBlocks()
Repaints the rectangle blocks which are marked as 'dirty'.
Functions related to OTTD's landscape.
Point RemapCoords(int x, int y, int z)
Map 3D world or tile coordinate to equivalent 2D coordinate as used in the viewports and smallmap.
TileIndex TileAddXY(TileIndex tile, int x, int y)
Adds a given offset to a tile.
static debug_inline TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
static debug_inline uint TileY(TileIndex tile)
Get the Y component of a tile.
static debug_inline uint TileX(TileIndex tile)
Get the X component of a tile.
void ShowQuery(EncodedString &&caption, EncodedString &&message, Window *parent, QueryCallbackProc *callback, bool focus)
Show a confirmation window with standard 'yes' and 'no' buttons The window is aligned to the centre o...
A number of safeguards to prevent using unsafe methods.
std::string GenerateDefaultSaveName()
Get the default name for a savegame or screenshot.
Functions/types related to saving and loading games.
static void ScreenshotConfirmationCallback(Window *, bool confirmed)
Callback on the confirmation window for huge screenshots.
static bool RealMakeScreenshot(ScreenshotType t, const std::string &name, uint32_t width, uint32_t height)
Make a screenshot.
void MakeScreenshotWithConfirm(ScreenshotType t)
Make a screenshot.
static ScreenshotType _confirmed_screenshot_type
Screenshot type the current query is about to confirm.
static const std::string_view HEIGHTMAP_NAME
Default filename of a saved heightmap.
std::string _screenshot_format_name
Extension of the current screenshot format.
static bool MakeSmallScreenshot(bool crashlog)
Make a screenshot of the current screen.
bool MakeMinimapWorldScreenshot()
Make a minimap screenshot.
static void HeightmapCallback(void *buffer, uint y, uint, uint n)
Callback for generating a heightmap.
static bool MakeLargeWorldScreenshot(ScreenshotType t, uint32_t width=0, uint32_t height=0)
Make a screenshot of the map.
std::string_view GetCurrentScreenshotExtension()
Get filename extension of current screenshot file format.
static std::string _screenshot_name
Filename of the screenshot file.
static ScreenshotProvider * GetScreenshotProvider()
Get the screenshot provider for the selected format.
static void CurrentScreenCallback(void *buf, uint y, uint pitch, uint n)
Callback of the screenshot generator that dumps the current video buffer.
bool MakeScreenshot(ScreenshotType t, const std::string &name, uint32_t width, uint32_t height)
Schedule making a screenshot.
static void LargeWorldCallback(Viewport &vp, void *buf, uint y, uint pitch, uint n)
generate a large piece of the world
std::string _full_screenshot_path
Pathname of the screenshot file.
bool MakeHeightmapScreenshot(std::string_view filename)
Make a heightmap of the current map.
static std::string_view MakeScreenshotName(std::string_view default_fn, std::string_view ext, bool crashlog=false)
Construct a pathname for a screenshot file.
uint _heightmap_highest_peak
When saving a heightmap, this contains the highest peak on the map.
static const std::string_view SCREENSHOT_NAME
Default filename of a saved screenshot.
static Viewport SetupScreenshotViewport(ScreenshotType t, uint32_t width=0, uint32_t height=0)
Configure a Viewport for rendering (a part of) the map into a screenshot.
Functions to make screenshots.
ScreenshotType
Type of requested screenshot.
@ SC_VIEWPORT
Screenshot of viewport.
@ SC_CRASHLOG
Raw screenshot from blitter buffer.
@ SC_ZOOMEDIN
Fully zoomed in screenshot of the visible area.
@ SC_HEIGHTMAP
Heightmap of the world.
@ SC_WORLD
World screenshot.
@ SC_MINIMAP
Minimap screenshot.
@ SC_DEFAULTZOOM
Zoomed to default zoom level screenshot of the visible area.
void SetScreenshotWindowVisibility(bool hide)
Set the visibility of the screenshot window when taking a screenshot.
GUI functions related to screenshots.
Types related to screenshot providers.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
ClientSettings _settings_client
The current settings for this game.
uint32_t GetSmallMapOwnerPixels(TileIndex tile, TileType t, IncludeHeightmap include_heightmap)
Return the colour a tile would be displayed with in the small map in mode "Owner".
@ Never
Never include the heightmap.
Definition of base types and functions in a cross-platform compatible way.
#define lengthof(array)
Return the length of an fixed size array.
EncodedString GetEncodedString(StringID str)
Encode a string with no parameters into an encoded string.
Functions related to OTTD's strings.
Class to backup a specific variable and restore it upon destruction of this object to prevent stack v...
GUISettings gui
settings related to the GUI
bool freeform_edges
allow terraforming the tiles at the map edges
Data about how and where to blit pixels.
ZoomLevel zoom_min
minimum zoom out level
ConstructionSettings construction
construction of things in-game
static uint SizeY()
Get the size of the map along the Y.
static IterateWrapper Iterate()
Returns an iterable ensemble of all Tiles.
static debug_inline uint SizeX()
Get the size of the map along the X.
static debug_inline uint Size()
Get the size of the map.
static debug_inline uint MaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
Colour palette[256]
Current palette. Entry 0 has to be always fully transparent!
Helper struct to ensure the video buffer is locked and ready for drawing.
Data structure for viewport, display of a part of the world.
int top
Screen coordinate top edge of the viewport.
int width
Screen width of the viewport.
ZoomLevel zoom
The zoom level of the viewport.
int virtual_top
Virtual top coordinate.
int virtual_left
Virtual left coordinate.
int left
Screen coordinate left edge of the viewport.
int height
Screen height of the viewport.
Data structure for an opened window.
std::unique_ptr< ViewportData > viewport
Pointer to viewport data, if present.
Stuff related to the text buffer GUI.
Map writing/reading functions for tiles.
static debug_inline TileType GetTileType(Tile tile)
Get the tiletype of a given tile.
uint TilePixelHeight(Tile tile)
Returns the height of a tile in pixels.
static debug_inline uint TileHeight(Tile tile)
Returns the height of a tile.
static const uint TILE_SIZE
Tile size in world coordinates.
Base of all video drivers.
Functions related to (drawing on) viewports.
std::mutex lock
synchronization for playback status fields
Window * GetMainWindow()
Get the main window, i.e.
Window functions not directly related to making/drawing windows.
Functions, definitions and such used only by the GUI.
Functions related to zooming.
int ScaleByZoom(int value, ZoomLevel zoom)
Scale by zoom level, usually shift left (when zoom > ZoomLevel::Min) When shifting right,...
int UnScaleByZoom(int value, ZoomLevel zoom)
Scale by zoom level, usually shift right (when zoom > ZoomLevel::Min) When shifting right,...
@ WorldScreenshot
Default zoom level for the world screen shot.
@ Viewport
Default zoom level for viewports.