summaryrefslogtreecommitdiff
path: root/src/screenshot.cpp
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2010-08-15 23:32:36 +0000
committermichi_cc <michi_cc@openttd.org>2010-08-15 23:32:36 +0000
commit71ff3c4bb42a41422a628598abed68f7d94cb1df (patch)
tree9b2c052c19481a13bf68bb132034282f9b4f7fc1 /src/screenshot.cpp
parent0796ba3d26e385b673a6f3beb32bfd8e03cf9f7e (diff)
downloadopenttd-71ff3c4bb42a41422a628598abed68f7d94cb1df.tar.xz
(svn r20508) -Add [FS#3973]: A new screenshot type that makes a zoomed-in screenshot of the visible viewport. (Eddi)
Diffstat (limited to 'src/screenshot.cpp')
-rw-r--r--src/screenshot.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/screenshot.cpp b/src/screenshot.cpp
index 84e44c192..3f0c540e9 100644
--- a/src/screenshot.cpp
+++ b/src/screenshot.cpp
@@ -23,6 +23,8 @@
#include "company_func.h"
#include "strings_func.h"
#include "gui.h"
+#include "window_gui.h"
+#include "window_func.h"
#include "table/strings.h"
@@ -602,12 +604,34 @@ static const char *MakeScreenshotName(const char *ext)
return _full_screenshot_name;
}
+/** Make a screenshot of the current screen. */
static bool MakeSmallScreenshot()
{
const ScreenshotFormat *sf = _screenshot_formats + _cur_screenshot_format;
return sf->proc(MakeScreenshotName(sf->extension), CurrentScreenCallback, NULL, _screen.width, _screen.height, BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth(), _cur_palette);
}
+/** Make a zoomed-in screenshot of the currently visible area. */
+static bool MakeZoomedInScreenshot()
+{
+ Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
+ ViewPort vp;
+
+ vp.zoom = ZOOM_LVL_WORLD_SCREENSHOT;
+ vp.left = w->viewport->left;
+ vp.top = w->viewport->top;
+ vp.virtual_left = w->viewport->virtual_left;
+ vp.virtual_top = w->viewport->virtual_top;
+ vp.virtual_width = w->viewport->virtual_width;
+ vp.width = vp.virtual_width;
+ vp.virtual_height = w->viewport->virtual_height;
+ vp.height = vp.virtual_height;
+
+ const ScreenshotFormat *sf = _screenshot_formats + _cur_screenshot_format;
+ return sf->proc(MakeScreenshotName(sf->extension), LargeWorldCallback, &vp, vp.width, vp.height, BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth(), _cur_palette);
+}
+
+/** Make a screenshot of the whole map. */
static bool MakeWorldScreenshot()
{
ViewPort vp;
@@ -654,6 +678,10 @@ bool MakeScreenshot(ScreenshotType t, const char *name)
ret = MakeSmallScreenshot();
break;
+ case SC_ZOOMEDIN:
+ ret = MakeZoomedInScreenshot();
+ break;
+
case SC_WORLD:
ret = MakeWorldScreenshot();
break;