Merge tag '1.11.2' into 1.11

This commit is contained in:
Sergii Pylypenko
2021-05-07 21:53:27 +03:00
99 changed files with 1556 additions and 994 deletions

View File

@@ -877,7 +877,7 @@ static ScreenshotType _confirmed_screenshot_type; ///< Screenshot type the curre
*/
static void ScreenshotConfirmationCallback(Window *w, bool confirmed)
{
if (confirmed) MakeScreenshot(_confirmed_screenshot_type, nullptr);
if (confirmed) MakeScreenshot(_confirmed_screenshot_type, {});
}
/**
@@ -903,24 +903,20 @@ void MakeScreenshotWithConfirm(ScreenshotType t)
ShowQuery(STR_WARNING_SCREENSHOT_SIZE_CAPTION, STR_WARNING_SCREENSHOT_SIZE_MESSAGE, nullptr, ScreenshotConfirmationCallback);
} else {
/* Less than 64M pixels, just do it */
MakeScreenshot(t, nullptr);
MakeScreenshot(t, {});
}
}
/**
* Make a screenshot.
* Unconditionally take a screenshot of the requested type.
* @param t the type of screenshot to make.
* @param name the name to give to the screenshot.
* @param width the width of the screenshot of, or 0 for current viewport width (only works for SC_ZOOMEDIN and SC_DEFAULTZOOM).
* @param height the height of the screenshot of, or 0 for current viewport height (only works for SC_ZOOMEDIN and SC_DEFAULTZOOM).
* @return true iff the screenshot was made successfully
* @see MakeScreenshotWithConfirm
*/
bool MakeScreenshot(ScreenshotType t, const char *name, uint32 width, uint32 height)
static bool RealMakeScreenshot(ScreenshotType t, std::string name, uint32 width, uint32 height)
{
VideoDriver::VideoBufferLocker lock;
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
@@ -931,7 +927,7 @@ bool MakeScreenshot(ScreenshotType t, const char *name, uint32 width, uint32 hei
}
_screenshot_name[0] = '\0';
if (name != nullptr) strecpy(_screenshot_name, name, lastof(_screenshot_name));
if (!name.empty()) strecpy(_screenshot_name, name.c_str(), lastof(_screenshot_name));
bool ret;
switch (t) {
@@ -970,7 +966,7 @@ bool MakeScreenshot(ScreenshotType t, const char *name, uint32 width, uint32 hei
if (t == SC_HEIGHTMAP) {
SetDParamStr(0, _screenshot_name);
SetDParam(1, _heightmap_highest_peak);
ShowErrorMessage(STR_MESSAGE_HEIGHTMAP_SUCCESSFULLY, INVALID_STRING_ID, WL_CRITICAL);
ShowErrorMessage(STR_MESSAGE_HEIGHTMAP_SUCCESSFULLY, INVALID_STRING_ID, WL_WARNING);
} else {
SetDParamStr(0, _screenshot_name);
// No need for message when we're doing cloudsave
@@ -983,6 +979,32 @@ bool MakeScreenshot(ScreenshotType t, const char *name, uint32 width, uint32 hei
return ret;
}
/**
* Schedule making a screenshot.
* Unconditionally take a screenshot of the requested type.
* @param t the type of screenshot to make.
* @param name the name to give to the screenshot.
* @param width the width of the screenshot of, or 0 for current viewport width (only works for SC_ZOOMEDIN and SC_DEFAULTZOOM).
* @param height the height of the screenshot of, or 0 for current viewport height (only works for SC_ZOOMEDIN and SC_DEFAULTZOOM).
* @return true iff the screenshot was successfully made.
* @see MakeScreenshotWithConfirm
*/
bool MakeScreenshot(ScreenshotType t, std::string name, uint32 width, uint32 height)
{
if (t == SC_CRASHLOG) {
/* Video buffer might or might not be locked. */
VideoDriver::VideoBufferLocker lock;
return RealMakeScreenshot(t, name, width, height);
}
VideoDriver::GetInstance()->QueueOnMainThread([=] { // Capture by value to not break scope.
RealMakeScreenshot(t, name, width, height);
});
return true;
}
/**
* Return the owner of a tile to display it with in the small map in mode "Owner".