screenshot.c
changeset 4184 541f819f2125
parent 4079 0baf04d1b0aa
child 4185 33a0f0f80965
--- a/screenshot.c	Thu Jul 27 14:07:51 2006 +0000
+++ b/screenshot.c	Fri Jul 28 21:51:00 2006 +0000
@@ -16,6 +16,7 @@
 char _screenshot_format_name[8];
 uint _num_screenshot_formats;
 uint _cur_screenshot_format;
+ScreenshotType current_screenshot_type;
 
 // called by the ScreenShot proc to generate screenshot lines.
 typedef void ScreenshotCallback(void *userdata, Pixel *buf, uint y, uint pitch, uint n);
@@ -431,6 +432,7 @@
 		}
 	_cur_screenshot_format = j;
 	_num_screenshot_formats = lengthof(_screenshot_formats);
+	make_screenshot = SC_NONE;
 }
 
 const char *GetScreenshotFormatDesc(int i)
@@ -518,27 +520,52 @@
 	return filename;
 }
 
-bool MakeScreenshot(void)
+void SetScreenshotType(ScreenshotType t)
+{
+	current_screenshot_type = t;
+}
+
+bool IsScreenshotRequested(void)
+{
+	return (current_screenshot_type != SC_NONE);
+}
+
+static bool MakeSmallScreenshot(void)
 {
 	const ScreenshotFormat *sf = _screenshot_formats + _cur_screenshot_format;
 	return sf->proc(MakeScreenshotName(sf->extension), CurrentScreenCallback, NULL, _screen.width, _screen.height, 8, _cur_palette);
 }
 
-bool MakeWorldScreenshot(int left, int top, int width, int height, int zoom)
+static bool MakeWorldScreenshot(void)
 {
 	ViewPort vp;
 	const ScreenshotFormat *sf;
 
-	vp.zoom = zoom;
+	vp.zoom = 0;
 	vp.left = 0;
 	vp.top = 0;
-	vp.virtual_width = width;
-	vp.width = width >> zoom;
-	vp.virtual_height = height;
-	vp.height = height >> zoom;
-	vp.virtual_left = left;
-	vp.virtual_top = top;
+	vp.virtual_left = -(int)MapMaxX() * TILE_PIXELS;
+	vp.virtual_top = 0;
+	vp.virtual_width = (MapMaxX() + MapMaxY()) * TILE_PIXELS;
+	vp.width = vp.virtual_width;
+	vp.virtual_height = (MapMaxX() + MapMaxY()) * TILE_PIXELS >> 1;
+	vp.height = vp.virtual_height;
 
 	sf = _screenshot_formats + _cur_screenshot_format;
 	return sf->proc(MakeScreenshotName(sf->extension), LargeWorldCallback, &vp, vp.width, vp.height, 8, _cur_palette);
 }
+
+bool MakeScreenshot(void)
+{
+	switch (current_screenshot_type) {
+		case SC_VIEWPORT:
+			UndrawMouseCursor();
+			current_screenshot_type = SC_NONE;
+			return MakeSmallScreenshot();
+		case SC_WORLD:
+			current_screenshot_type = SC_NONE;
+			return MakeWorldScreenshot();
+		default: return false;
+	}
+}
+