Changeset - r26056:63fb51e65511
[Not reviewed]
master
0 3 0
Tyler Trahan - 2 years ago 2021-11-07 16:41:24
tyler@tylertrahan.com
Fix: Don't show screenshot GUI in screenshots (#9674)
3 files changed with 26 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/screenshot.cpp
Show inline comments
 
@@ -9,12 +9,13 @@
 

	
 
#include "stdafx.h"
 
#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 "core/endian_func.hpp"
 
#include "saveload/saveload.h"
 
#include "company_base.h"
 
#include "company_func.h"
 
@@ -906,14 +907,16 @@ static bool RealMakeScreenshot(Screensho
 
{
 
	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
 
		 * of the previous screenshot in the 'successful' message instead of the
 
		 * name of the new screenshot (or an empty name). */
 
		SetScreenshotWindowVisibility(true);
 
		UndrawMouseCursor();
 
		DrawDirtyBlocks();
 
		SetScreenshotWindowVisibility(false);
 
	}
 

	
 
	_screenshot_name[0] = '\0';
 
	if (!name.empty()) strecpy(_screenshot_name, name.c_str(), lastof(_screenshot_name));
 

	
 
	bool ret;
src/screenshot_gui.cpp
Show inline comments
 
@@ -10,12 +10,13 @@
 
#include "stdafx.h"
 
#include "window_func.h"
 
#include "window_gui.h"
 
#include "screenshot.h"
 
#include "widgets/screenshot_widget.h"
 
#include "table/strings.h"
 
#include "gfx_func.h"
 

	
 
struct ScreenshotWindow : Window {
 
	ScreenshotWindow(WindowDesc *desc) : Window(desc)
 
	{
 
		this->CreateNestedTree();
 
		this->FinishInitNested();
 
@@ -69,6 +70,27 @@ static WindowDesc _screenshot_window_des
 

	
 
void ShowScreenshotWindow()
 
{
 
	CloseWindowById(WC_SCREENSHOT, 0);
 
	new ScreenshotWindow(&_screenshot_window_desc);
 
}
 

	
 
/**
 
 * Set the visibility of the screenshot window when taking a screenshot.
 
 * @param hide Are we hiding the window or showing it again after the screenshot is taken?
 
 */
 
void SetScreenshotWindowVisibility(bool hide)
 
{
 
	ScreenshotWindow *scw = (ScreenshotWindow *)FindWindowById(WC_SCREENSHOT, 0);
 

	
 
	if (scw == nullptr) return;
 

	
 
	if (hide) {
 
		/* Set dirty the screen area where the window is covering (not the window itself), then move window off screen. */
 
		scw->SetDirty();
 
		scw->left += 2 * _screen.width;
 
	} else {
 
		/* Return window to original position. */
 
		scw->left -= 2 * _screen.width;
 
		scw->SetDirty();
 
	}
 
}
src/screenshot_gui.h
Show inline comments
 
@@ -8,8 +8,9 @@
 
 /** @file screenshot_gui.h GUI functions related to screenshots. */
 

	
 
#ifndef SCREENSHOT_GUI_H
 
#define SCREENSHOT_GUI_H
 

	
 
void ShowScreenshotWindow();
 
void SetScreenshotWindowVisibility(bool hide);
 

	
 
#endif /* SCREENSHOT_GUI_H */
0 comments (0 inline, 0 general)