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);
98 _screen.dst_ptr = buf;
99 _screen.width = pitch;
101 _screen.pitch = pitch;
108 dpi.width = vp->
width;
116 while (vp->
width - left != 0) {
117 wx = std::min(vp->
width - left, 1600);
129 _screen = old_screen;
140static const char *
MakeScreenshotName(std::string_view default_fn, std::string_view ext,
bool crashlog =
false)
164 for (uint serial = 1;; serial++) {
167 if (!generate)
break;
181 if (provider ==
nullptr)
return false;
201 assert(width == 0 && height == 0);
204 vp.virtual_left = w->
viewport->virtual_left;
205 vp.virtual_top = w->
viewport->virtual_top;
206 vp.virtual_width = w->
viewport->virtual_width;
207 vp.virtual_height = w->
viewport->virtual_height;
212 vp.width = _screen.width;
213 vp.height = _screen.height;
218 assert(width == 0 && height == 0);
241 vp.overlay =
nullptr;
248 vp.virtual_left = w->
viewport->virtual_left;
249 vp.virtual_top = w->
viewport->virtual_top;
251 if (width == 0 || height == 0) {
252 vp.virtual_width = w->
viewport->virtual_width;
253 vp.virtual_height = w->
viewport->virtual_height;
255 vp.virtual_width = width << vp.zoom;
256 vp.virtual_height = height << vp.zoom;
264 vp.overlay =
nullptr;
282 if (provider ==
nullptr)
return false;
299 uint8_t *buf = (uint8_t *)buffer;
320 if (provider ==
nullptr)
return false;
323 for (uint i = 0; i <
lengthof(palette); i++) {
364 if (width * height > 8192 * 8192) {
420 if (provider ==
nullptr) {
476static void MinimapScreenCallback(
void *,
void *buf, uint y, uint pitch, uint n)
478 uint32_t *ubuf = (uint32_t *)buf;
479 uint num = (pitch * n);
480 for (uint i = 0; i < num; i++) {
481 uint row = y + (int)(i / pitch);
487 uint32_t colour_buf = 0;
503 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.
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(const std::string &filename)
Test whether the given filename exists.
Functions for Standard In/Out file operations.
const char * 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 CurrentScreenCallback(void *, void *buf, uint y, uint pitch, uint n)
Callback of the screenshot generator that dumps the current video buffer.
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.
std::string _screenshot_format_name
Extension of the current screenshot format.
static bool MakeSmallScreenshot(bool crashlog)
Make a screenshot of the current screen.
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 const char *const SCREENSHOT_NAME
Default filename of a saved screenshot.
bool MakeMinimapWorldScreenshot()
Make a minimap screenshot.
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.
bool MakeScreenshot(ScreenshotType t, const std::string &name, uint32_t width, uint32_t height)
Schedule making a screenshot.
std::string _full_screenshot_path
Pathname of the screenshot file.
static void LargeWorldCallback(void *userdata, void *buf, uint y, uint pitch, uint n)
generate a large piece of the world
static const char *const HEIGHTMAP_NAME
Default filename of a saved heightmap.
uint _heightmap_highest_peak
When saving a heightmap, this contains the highest peak on the map.
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.
static const char * MakeScreenshotName(std::string_view default_fn, std::string_view ext, bool crashlog=false)
Construct a pathname for a screenshot file.
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 > ZOOM_LVL_MIN) When shifting right,...
int UnScaleByZoom(int value, ZoomLevel zoom)
Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_MIN) When shifting right,...
@ ZOOM_LVL_WORLD_SCREENSHOT
Default zoom level for the world screen shot.
@ ZOOM_LVL_VIEWPORT
Default zoom level for viewports.