OpenTTD Source: src/screenshot.cpp Source File

OpenTTD Source 15.3

screenshot.cpp
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#include "stdafx.h"
11#include "core/backup_type.hpp"
12#include "fileio_func.h"
13#include "viewport_func.h"
14#include "gfx_func.h"
15#include "screenshot.h"
16#include "screenshot_gui.h"
17#include "blitter/factory.hpp"
18#include "zoom_func.h"
19#include "saveload/saveload.h"
20#include "company_func.h"
21#include "strings_func.h"
22#include "error.h"
23#include "textbuf_gui.h"
24#include "window_gui.h"
25#include "window_func.h"
26#include "tile_map.h"
27#include "landscape.h"
28#include "video/video_driver.hpp"
29#include "smallmap_gui.h"
30#include "screenshot_type.h"
31
32#include "table/strings.h"
33
34#include "safeguards.h"
35
36 static const std::string_view SCREENSHOT_NAME = "screenshot";
37 static const std::string_view HEIGHTMAP_NAME = "heightmap";
38
39std::string _screenshot_format_name;
40 static std::string _screenshot_name;
41std::string _full_screenshot_path;
42uint _heightmap_highest_peak;
43
49 static const ScreenshotProvider *GetScreenshotProvider()
50{
51 const auto &providers = ProviderManager<ScreenshotProvider>::GetProviders();
52 if (providers.empty()) return nullptr;
53
54 auto it = std::ranges::find(providers, _screenshot_format_name, &ScreenshotProvider::GetName);
55 if (it != std::end(providers)) return *it;
56
57 return providers.front();
58}
59
61std::string_view GetCurrentScreenshotExtension()
62{
63 auto provider = GetScreenshotProvider();
64 if (provider == nullptr) return {};
65
66 return provider->GetName();
67}
68
73 static void CurrentScreenCallback(void *buf, uint y, uint pitch, uint n)
74{
75 Blitter *blitter = BlitterFactory::GetCurrentBlitter();
76 void *src = blitter->MoveTo(_screen.dst_ptr, 0, y);
77 blitter->CopyImageToBuffer(src, buf, _screen.width, n, pitch);
78}
79
88 static void LargeWorldCallback(Viewport &vp, void *buf, uint y, uint pitch, uint n)
89{
90 DrawPixelInfo dpi{
91 .dst_ptr = buf,
92 .left = 0,
93 .top = static_cast<int>(y),
94 .width = vp.width,
95 .height = static_cast<int>(n),
96 .pitch = static_cast<int>(pitch),
97 .zoom = ZoomLevel::WorldScreenshot
98 };
99
100 /* We are no longer rendering to the screen */
101 AutoRestoreBackup screen_backup(_screen, {
102 .dst_ptr = buf,
103 .left = 0,
104 .top = 0,
105 .width = static_cast<int>(pitch),
106 .height = static_cast<int>(n),
107 .pitch = static_cast<int>(pitch),
108 .zoom = ZoomLevel::Min
109 });
110 AutoRestoreBackup disable_anim_backup(_screen_disable_anim, true);
111 AutoRestoreBackup dpi_backup(_cur_dpi, &dpi);
112
113 /* Render viewport in blocks of 1600 pixels width */
114 int left = 0;
115 while (vp.width - left != 0) {
116 int wx = std::min(vp.width - left, 1600);
117 left += wx;
118
119 ViewportDoDraw(vp,
120 ScaleByZoom(left - wx - vp.left, vp.zoom) + vp.virtual_left,
121 ScaleByZoom(y - vp.top, vp.zoom) + vp.virtual_top,
122 ScaleByZoom(left - vp.left, vp.zoom) + vp.virtual_left,
123 ScaleByZoom((y + n) - vp.top, vp.zoom) + vp.virtual_top
124 );
125 }
126}
127
135 static std::string_view MakeScreenshotName(std::string_view default_fn, std::string_view ext, bool crashlog = false)
136{
137 bool generate = _screenshot_name.empty();
138
139 if (generate) {
140 if (_game_mode == GM_EDITOR || _game_mode == GM_MENU || _local_company == COMPANY_SPECTATOR) {
141 _screenshot_name = default_fn;
142 } else {
143 _screenshot_name = GenerateDefaultSaveName();
144 }
145 }
146
147 /* Handle user-specified filenames ending in # with automatic numbering */
148 if (_screenshot_name.ends_with("#")) {
149 generate = true;
150 _screenshot_name.pop_back();
151 }
152
153 size_t len = _screenshot_name.size();
154 /* Add extension to screenshot file */
155 format_append(_screenshot_name, ".{}", ext);
156
157 std::string_view screenshot_dir = crashlog ? _personal_dir : FiosGetScreenshotDir();
158
159 for (uint serial = 1;; serial++) {
160 _full_screenshot_path = fmt::format("{}{}", screenshot_dir, _screenshot_name);
161
162 if (!generate) break; // allow overwriting of non-automatic filenames
163 if (!FileExists(_full_screenshot_path)) break;
164 /* If file exists try another one with same name, but just with a higher index */
165 _screenshot_name.erase(len);
166 format_append(_screenshot_name, "#{}.{}", serial, ext);
167 }
168
169 return _full_screenshot_path;
170}
171
173 static bool MakeSmallScreenshot(bool crashlog)
174{
175 auto provider = GetScreenshotProvider();
176 if (provider == nullptr) return false;
177
178 return provider->MakeImage(MakeScreenshotName(SCREENSHOT_NAME, provider->GetName(), crashlog), CurrentScreenCallback, _screen.width, _screen.height,
179 BlitterFactory::GetCurrentBlitter()->GetScreenDepth(), _cur_palette.palette);
180}
181
189 static Viewport SetupScreenshotViewport(ScreenshotType t, uint32_t width = 0, uint32_t height = 0)
190{
191 Viewport vp{};
192
193 switch(t) {
194 case SC_VIEWPORT:
195 case SC_CRASHLOG: {
196 assert(width == 0 && height == 0);
197
198 Window *w = GetMainWindow();
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;
203
204 /* Compute pixel coordinates */
205 vp.left = 0;
206 vp.top = 0;
207 vp.width = _screen.width;
208 vp.height = _screen.height;
209 vp.overlay = w->viewport->overlay;
210 break;
211 }
212 case SC_WORLD: {
213 assert(width == 0 && height == 0);
214
215 /* Determine world coordinates of screenshot */
216 vp.zoom = ZoomLevel::WorldScreenshot;
217
218 TileIndex north_tile = _settings_game.construction.freeform_edges ? TileXY(1, 1) : TileXY(0, 0);
219 TileIndex south_tile{Map::Size() - 1};
220
221 /* We need to account for a hill or high building at tile 0,0. */
222 int extra_height_top = TilePixelHeight(north_tile) + 150;
223 /* If there is a hill at the bottom don't create a large black area. */
224 int reclaim_height_bottom = TilePixelHeight(south_tile);
225
226 vp.virtual_left = RemapCoords(TileX(south_tile) * TILE_SIZE, TileY(north_tile) * TILE_SIZE, 0).x;
227 vp.virtual_top = RemapCoords(TileX(north_tile) * TILE_SIZE, TileY(north_tile) * TILE_SIZE, extra_height_top).y;
228 vp.virtual_width = RemapCoords(TileX(north_tile) * TILE_SIZE, TileY(south_tile) * TILE_SIZE, 0).x - vp.virtual_left + 1;
229 vp.virtual_height = RemapCoords(TileX(south_tile) * TILE_SIZE, TileY(south_tile) * TILE_SIZE, reclaim_height_bottom).y - vp.virtual_top + 1;
230
231 /* Compute pixel coordinates */
232 vp.left = 0;
233 vp.top = 0;
234 vp.width = UnScaleByZoom(vp.virtual_width, vp.zoom);
235 vp.height = UnScaleByZoom(vp.virtual_height, vp.zoom);
236 vp.overlay = nullptr;
237 break;
238 }
239 default: {
240 vp.zoom = (t == SC_ZOOMEDIN) ? _settings_client.gui.zoom_min : ZoomLevel::Viewport;
241
242 Window *w = GetMainWindow();
243 vp.virtual_left = w->viewport->virtual_left;
244 vp.virtual_top = w->viewport->virtual_top;
245
246 if (width == 0 || height == 0) {
247 vp.virtual_width = w->viewport->virtual_width;
248 vp.virtual_height = w->viewport->virtual_height;
249 } else {
250 vp.virtual_width = width << to_underlying(vp.zoom);
251 vp.virtual_height = height << to_underlying(vp.zoom);
252 }
253
254 /* Compute pixel coordinates */
255 vp.left = 0;
256 vp.top = 0;
257 vp.width = UnScaleByZoom(vp.virtual_width, vp.zoom);
258 vp.height = UnScaleByZoom(vp.virtual_height, vp.zoom);
259 vp.overlay = nullptr;
260 break;
261 }
262 }
263
264 return vp;
265}
266
274 static bool MakeLargeWorldScreenshot(ScreenshotType t, uint32_t width = 0, uint32_t height = 0)
275{
276 auto provider = GetScreenshotProvider();
277 if (provider == nullptr) return false;
278
279 Viewport vp = SetupScreenshotViewport(t, width, height);
280
281 return provider->MakeImage(MakeScreenshotName(SCREENSHOT_NAME, provider->GetName()),
282 [&](void *buf, uint y, uint pitch, uint n) {
283 LargeWorldCallback(vp, buf, y, pitch, n);
284 }, vp.width, vp.height, BlitterFactory::GetCurrentBlitter()->GetScreenDepth(), _cur_palette.palette);
285}
286
294 static void HeightmapCallback(void *buffer, uint y, uint, uint n)
295{
296 uint8_t *buf = (uint8_t *)buffer;
297 while (n > 0) {
298 TileIndex ti = TileXY(Map::MaxX(), y);
299 for (uint x = Map::MaxX(); true; x--) {
300 *buf = 256 * TileHeight(ti) / (1 + _heightmap_highest_peak);
301 buf++;
302 if (x == 0) break;
303 ti = TileAddXY(ti, -1, 0);
304 }
305 y++;
306 n--;
307 }
308}
309
314 bool MakeHeightmapScreenshot(std::string_view filename)
315{
316 auto provider = GetScreenshotProvider();
317 if (provider == nullptr) return false;
318
319 Colour palette[256];
320 for (uint i = 0; i < lengthof(palette); i++) {
321 palette[i].a = 0xff;
322 palette[i].r = i;
323 palette[i].g = i;
324 palette[i].b = i;
325 }
326
327 _heightmap_highest_peak = 0;
328 for (const auto tile : Map::Iterate()) {
329 uint h = TileHeight(tile);
330 _heightmap_highest_peak = std::max(h, _heightmap_highest_peak);
331 }
332
333 return provider->MakeImage(filename, HeightmapCallback, Map::SizeX(), Map::SizeY(), 8, palette);
334}
335
336 static ScreenshotType _confirmed_screenshot_type;
337
342 static void ScreenshotConfirmationCallback(Window *, bool confirmed)
343{
344 if (confirmed) MakeScreenshot(_confirmed_screenshot_type, {});
345}
346
353 void MakeScreenshotWithConfirm(ScreenshotType t)
354{
355 Viewport vp = SetupScreenshotViewport(t);
356
357 bool heightmap_or_minimap = t == SC_HEIGHTMAP || t == SC_MINIMAP;
358 uint64_t width = (heightmap_or_minimap ? Map::SizeX() : vp.width);
359 uint64_t height = (heightmap_or_minimap ? Map::SizeY() : vp.height);
360
361 if (width * height > 8192 * 8192) {
362 /* Ask for confirmation */
363 _confirmed_screenshot_type = t;
364 ShowQuery(
365 GetEncodedString(STR_WARNING_SCREENSHOT_SIZE_CAPTION),
366 GetEncodedString(STR_WARNING_SCREENSHOT_SIZE_MESSAGE, width, height), nullptr, ScreenshotConfirmationCallback);
367 } else {
368 /* Less than 64M pixels, just do it */
369 MakeScreenshot(t, {});
370 }
371}
372
381 static bool RealMakeScreenshot(ScreenshotType t, const std::string &name, uint32_t width, uint32_t height)
382{
383 if (t == SC_VIEWPORT) {
384 /* First draw the dirty parts of the screen and only then change the name
385 * of the screenshot. This way the screenshot will always show the name
386 * of the previous screenshot in the 'successful' message instead of the
387 * name of the new screenshot (or an empty name). */
388 SetScreenshotWindowVisibility(true);
389 UndrawMouseCursor();
390 DrawDirtyBlocks();
391 SetScreenshotWindowVisibility(false);
392 }
393
394 _screenshot_name = name;
395
396 bool ret;
397 switch (t) {
398 case SC_VIEWPORT:
399 ret = MakeSmallScreenshot(false);
400 break;
401
402 case SC_CRASHLOG:
403 ret = MakeSmallScreenshot(true);
404 break;
405
406 case SC_ZOOMEDIN:
407 case SC_DEFAULTZOOM:
408 ret = MakeLargeWorldScreenshot(t, width, height);
409 break;
410
411 case SC_WORLD:
412 ret = MakeLargeWorldScreenshot(t);
413 break;
414
415 case SC_HEIGHTMAP: {
416 auto provider = GetScreenshotProvider();
417 if (provider == nullptr) {
418 ret = false;
419 } else {
420 ret = MakeHeightmapScreenshot(MakeScreenshotName(HEIGHTMAP_NAME, provider->GetName()));
421 }
422 break;
423 }
424
425 case SC_MINIMAP:
426 ret = MakeMinimapWorldScreenshot();
427 break;
428
429 default:
430 NOT_REACHED();
431 }
432
433 if (ret) {
434 if (t == SC_HEIGHTMAP) {
435 ShowErrorMessage(GetEncodedString(STR_MESSAGE_HEIGHTMAP_SUCCESSFULLY, _screenshot_name, _heightmap_highest_peak), {}, WL_WARNING);
436 } else {
437 ShowErrorMessage(GetEncodedString(STR_MESSAGE_SCREENSHOT_SUCCESSFULLY, _screenshot_name), {}, WL_WARNING);
438 }
439 } else {
440 ShowErrorMessage(GetEncodedString(STR_ERROR_SCREENSHOT_FAILED), {}, WL_ERROR);
441 }
442
443 return ret;
444}
445
456 bool MakeScreenshot(ScreenshotType t, const std::string &name, uint32_t width, uint32_t height)
457{
458 if (t == SC_CRASHLOG) {
459 /* Video buffer might or might not be locked. */
460 VideoDriver::VideoBufferLocker lock;
461
462 return RealMakeScreenshot(t, name, width, height);
463 }
464
465 VideoDriver::GetInstance()->QueueOnMainThread([=] { // Capture by value to not break scope.
466 RealMakeScreenshot(t, name, width, height);
467 });
468
469 return true;
470}
471
472
473static void MinimapScreenCallback(void *buf, uint y, uint pitch, uint n)
474{
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);
479 uint col = (Map::SizeX() - 1) - (i % pitch);
480
481 TileIndex tile = TileXY(col, row);
482 uint8_t val = GetSmallMapOwnerPixels(tile, GetTileType(tile), IncludeHeightmap::Never) & 0xFF;
483
484 uint32_t colour_buf = 0;
485 colour_buf = (_cur_palette.palette[val].b << 0);
486 colour_buf |= (_cur_palette.palette[val].g << 8);
487 colour_buf |= (_cur_palette.palette[val].r << 16);
488
489 *ubuf = colour_buf;
490 ubuf++; // Skip alpha
491 }
492}
493
497 bool MakeMinimapWorldScreenshot()
498{
499 auto provider = GetScreenshotProvider();
500 if (provider == nullptr) return false;
501
502 return provider->MakeImage(MakeScreenshotName(SCREENSHOT_NAME, provider->GetName()), MinimapScreenCallback, Map::SizeX(), Map::SizeY(), 32, _cur_palette.palette);
503}
backup_type.hpp
Class for backupping variables and making sure they are restored later.
BlitterFactory::GetCurrentBlitter
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
Definition factory.hpp:136
Blitter
How all blitters should look like.
Definition base.hpp:29
Blitter::MoveTo
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...
Blitter::GetScreenDepth
virtual uint8_t GetScreenDepth()=0
Get the screen depth this blitter works for.
Blitter::CopyImageToBuffer
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.
ProviderManager::GetProviders
static std::vector< const TProviderType * > & GetProviders()
Get the currently known providers.
Definition provider_manager.h:46
ScreenshotProvider
Base interface for a SoundLoader implementation.
Definition screenshot_type.h:27
VideoDriver::QueueOnMainThread
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.
Definition video_driver.hpp:180
VideoDriver::GetInstance
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
Definition video_driver.hpp:192
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition company_cmd.cpp:55
company_func.h
Functions related to companies.
COMPANY_SPECTATOR
static constexpr CompanyID COMPANY_SPECTATOR
The client is spectating.
Definition company_type.h:21
to_underlying
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23)
Definition enum_type.hpp:17
error.h
Functions related to errors.
WL_WARNING
@ WL_WARNING
Other information.
Definition error.h:25
WL_ERROR
@ WL_ERROR
Errors (eg. saving/loading failed)
Definition error.h:26
ShowErrorMessage
void ShowErrorMessage(EncodedString &&summary_msg, int x, int y, CommandCost &cc)
Display an error message in a window.
Definition error_gui.cpp:296
factory.hpp
Factory to 'query' all available blitters.
_personal_dir
std::string _personal_dir
custom directory for personal settings, saves, newgrf, etc.
Definition fileio.cpp:871
FileExists
bool FileExists(std::string_view filename)
Test whether the given filename exists.
Definition fileio.cpp:132
fileio_func.h
Functions for Standard In/Out file operations.
FiosGetScreenshotDir
std::string_view FiosGetScreenshotDir()
Get the directory for screenshots.
Definition fios.cpp:581
_screen_disable_anim
bool _screen_disable_anim
Disable palette animation (important for 32bpp-anim blitter during giant screenshot)
Definition gfx.cpp:46
gfx_func.h
Functions related to the gfx engine.
_cur_palette
Palette _cur_palette
Current palette.
Definition palette.cpp:24
DrawDirtyBlocks
void DrawDirtyBlocks()
Repaints the rectangle blocks which are marked as 'dirty'.
Definition gfx.cpp:1452
landscape.h
Functions related to OTTD's landscape.
RemapCoords
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.
Definition landscape.h:81
TileAddXY
TileIndex TileAddXY(TileIndex tile, int x, int y)
Adds a given offset to a tile.
Definition map_func.h:483
TileXY
static TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
Definition map_func.h:385
TileY
static uint TileY(TileIndex tile)
Get the Y component of a tile.
Definition map_func.h:438
TileX
static uint TileX(TileIndex tile)
Get the X component of a tile.
Definition map_func.h:428
ShowQuery
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...
Definition misc_gui.cpp:1204
safeguards.h
A number of safeguards to prevent using unsafe methods.
GenerateDefaultSaveName
std::string GenerateDefaultSaveName()
Get the default name for a savegame or screenshot.
Definition saveload.cpp:3375
saveload.h
Functions/types related to saving and loading games.
ScreenshotConfirmationCallback
static void ScreenshotConfirmationCallback(Window *, bool confirmed)
Callback on the confirmation window for huge screenshots.
Definition screenshot.cpp:342
RealMakeScreenshot
static bool RealMakeScreenshot(ScreenshotType t, const std::string &name, uint32_t width, uint32_t height)
Make a screenshot.
Definition screenshot.cpp:381
MakeScreenshotWithConfirm
void MakeScreenshotWithConfirm(ScreenshotType t)
Make a screenshot.
Definition screenshot.cpp:353
_confirmed_screenshot_type
static ScreenshotType _confirmed_screenshot_type
Screenshot type the current query is about to confirm.
Definition screenshot.cpp:336
HEIGHTMAP_NAME
static const std::string_view HEIGHTMAP_NAME
Default filename of a saved heightmap.
Definition screenshot.cpp:37
_screenshot_format_name
std::string _screenshot_format_name
Extension of the current screenshot format.
Definition screenshot.cpp:39
MakeSmallScreenshot
static bool MakeSmallScreenshot(bool crashlog)
Make a screenshot of the current screen.
Definition screenshot.cpp:173
MakeMinimapWorldScreenshot
bool MakeMinimapWorldScreenshot()
Make a minimap screenshot.
Definition screenshot.cpp:497
HeightmapCallback
static void HeightmapCallback(void *buffer, uint y, uint, uint n)
Callback for generating a heightmap.
Definition screenshot.cpp:294
MakeLargeWorldScreenshot
static bool MakeLargeWorldScreenshot(ScreenshotType t, uint32_t width=0, uint32_t height=0)
Make a screenshot of the map.
Definition screenshot.cpp:274
GetCurrentScreenshotExtension
std::string_view GetCurrentScreenshotExtension()
Get filename extension of current screenshot file format.
Definition screenshot.cpp:61
_screenshot_name
static std::string _screenshot_name
Filename of the screenshot file.
Definition screenshot.cpp:40
GetScreenshotProvider
static const ScreenshotProvider * GetScreenshotProvider()
Get the screenshot provider for the selected format.
Definition screenshot.cpp:49
CurrentScreenCallback
static void CurrentScreenCallback(void *buf, uint y, uint pitch, uint n)
Callback of the screenshot generator that dumps the current video buffer.
Definition screenshot.cpp:73
MakeScreenshot
bool MakeScreenshot(ScreenshotType t, const std::string &name, uint32_t width, uint32_t height)
Schedule making a screenshot.
Definition screenshot.cpp:456
LargeWorldCallback
static void LargeWorldCallback(Viewport &vp, void *buf, uint y, uint pitch, uint n)
generate a large piece of the world
Definition screenshot.cpp:88
_full_screenshot_path
std::string _full_screenshot_path
Pathname of the screenshot file.
Definition screenshot.cpp:41
MakeHeightmapScreenshot
bool MakeHeightmapScreenshot(std::string_view filename)
Make a heightmap of the current map.
Definition screenshot.cpp:314
MakeScreenshotName
static std::string_view MakeScreenshotName(std::string_view default_fn, std::string_view ext, bool crashlog=false)
Construct a pathname for a screenshot file.
Definition screenshot.cpp:135
_heightmap_highest_peak
uint _heightmap_highest_peak
When saving a heightmap, this contains the highest peak on the map.
Definition screenshot.cpp:42
SCREENSHOT_NAME
static const std::string_view SCREENSHOT_NAME
Default filename of a saved screenshot.
Definition screenshot.cpp:36
SetupScreenshotViewport
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.
Definition screenshot.cpp:189
screenshot.h
Functions to make screenshots.
ScreenshotType
ScreenshotType
Type of requested screenshot.
Definition screenshot.h:16
SC_VIEWPORT
@ SC_VIEWPORT
Screenshot of viewport.
Definition screenshot.h:17
SC_CRASHLOG
@ SC_CRASHLOG
Raw screenshot from blitter buffer.
Definition screenshot.h:18
SC_ZOOMEDIN
@ SC_ZOOMEDIN
Fully zoomed in screenshot of the visible area.
Definition screenshot.h:19
SC_HEIGHTMAP
@ SC_HEIGHTMAP
Heightmap of the world.
Definition screenshot.h:22
SC_WORLD
@ SC_WORLD
World screenshot.
Definition screenshot.h:21
SC_MINIMAP
@ SC_MINIMAP
Minimap screenshot.
Definition screenshot.h:23
SC_DEFAULTZOOM
@ SC_DEFAULTZOOM
Zoomed to default zoom level screenshot of the visible area.
Definition screenshot.h:20
SetScreenshotWindowVisibility
void SetScreenshotWindowVisibility(bool hide)
Set the visibility of the screenshot window when taking a screenshot.
Definition screenshot_gui.cpp:84
screenshot_gui.h
GUI functions related to screenshots.
screenshot_type.h
Types related to screenshot providers.
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition settings.cpp:61
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition settings.cpp:60
GetSmallMapOwnerPixels
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".
Definition smallmap_gui.cpp:580
smallmap_gui.h
Smallmap GUI functions.
IncludeHeightmap::Never
@ Never
Never include the heightmap.
stdafx.h
Definition of base types and functions in a cross-platform compatible way.
lengthof
#define lengthof(array)
Return the length of an fixed size array.
Definition stdafx.h:271
GetEncodedString
EncodedString GetEncodedString(StringID str)
Encode a string with no parameters into an encoded string.
Definition strings.cpp:90
strings_func.h
Functions related to OTTD's strings.
AutoRestoreBackup
Class to backup a specific variable and restore it upon destruction of this object to prevent stack v...
Definition backup_type.hpp:150
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition settings_type.h:650
ConstructionSettings::freeform_edges
bool freeform_edges
allow terraforming the tiles at the map edges
Definition settings_type.h:423
Coord2D::y
T y
Y coordinate.
Definition geometry_type.hpp:35
Coord2D::x
T x
X coordinate.
Definition geometry_type.hpp:34
DrawPixelInfo
Data about how and where to blit pixels.
Definition gfx_type.h:157
GUISettings::zoom_min
ZoomLevel zoom_min
minimum zoom out level
Definition settings_type.h:191
GameSettings::construction
ConstructionSettings construction
construction of things in-game
Definition settings_type.h:635
Map::SizeX
static uint SizeX()
Get the size of the map along the X.
Definition map_func.h:272
Map::SizeY
static uint SizeY()
Get the size of the map along the Y.
Definition map_func.h:281
Map::Iterate
static IterateWrapper Iterate()
Returns an iterable ensemble of all Tiles.
Definition map_func.h:375
Map::MaxX
static uint MaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
Definition map_func.h:299
Map::Size
static uint Size()
Get the size of the map.
Definition map_func.h:290
Palette::palette
Colour palette[256]
Current palette. Entry 0 has to be always fully transparent!
Definition gfx_type.h:374
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
VideoDriver::VideoBufferLocker
Helper struct to ensure the video buffer is locked and ready for drawing.
Definition video_driver.hpp:203
Viewport
Data structure for viewport, display of a part of the world.
Definition viewport_type.h:31
Viewport::top
int top
Screen coordinate top edge of the viewport.
Definition viewport_type.h:33
Viewport::width
int width
Screen width of the viewport.
Definition viewport_type.h:34
Viewport::zoom
ZoomLevel zoom
The zoom level of the viewport.
Definition viewport_type.h:42
Viewport::virtual_top
int virtual_top
Virtual top coordinate.
Definition viewport_type.h:38
Viewport::virtual_left
int virtual_left
Virtual left coordinate.
Definition viewport_type.h:37
Viewport::left
int left
Screen coordinate left edge of the viewport.
Definition viewport_type.h:32
Viewport::height
int height
Screen height of the viewport.
Definition viewport_type.h:35
Window
Data structure for an opened window.
Definition window_gui.h:274
Window::viewport
std::unique_ptr< ViewportData > viewport
Pointer to viewport data, if present.
Definition window_gui.h:319
textbuf_gui.h
Stuff related to the text buffer GUI.
tile_map.h
Map writing/reading functions for tiles.
TileHeight
static uint TileHeight(Tile tile)
Returns the height of a tile.
Definition tile_map.h:29
TilePixelHeight
uint TilePixelHeight(Tile tile)
Returns the height of a tile in pixels.
Definition tile_map.h:72
GetTileType
static TileType GetTileType(Tile tile)
Get the tiletype of a given tile.
Definition tile_map.h:96
TILE_SIZE
static constexpr uint TILE_SIZE
Tile size in world coordinates.
Definition tile_type.h:15
video_driver.hpp
Base of all video drivers.
viewport_func.h
Functions related to (drawing on) viewports.
lock
std::mutex lock
synchronization for playback status fields
Definition win32_m.cpp:35
GetMainWindow
Window * GetMainWindow()
Get the main window, i.e.
Definition window.cpp:1182
window_func.h
Window functions not directly related to making/drawing windows.
window_gui.h
Functions, definitions and such used only by the GUI.
zoom_func.h
Functions related to zooming.
ScaleByZoom
int ScaleByZoom(int value, ZoomLevel zoom)
Scale by zoom level, usually shift left (when zoom > ZoomLevel::Min) When shifting right,...
Definition zoom_func.h:22
UnScaleByZoom
int UnScaleByZoom(int value, ZoomLevel zoom)
Scale by zoom level, usually shift right (when zoom > ZoomLevel::Min) When shifting right,...
Definition zoom_func.h:34
ZoomLevel::Min
@ Min
Minimum zoom level.
ZoomLevel::WorldScreenshot
@ WorldScreenshot
Default zoom level for the world screen shot.
ZoomLevel::Viewport
@ Viewport
Default zoom level for viewports.