summaryrefslogtreecommitdiff
path: root/screenshot.c
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2006-07-28 21:51:00 +0000
committerbelugas <belugas@openttd.org>2006-07-28 21:51:00 +0000
commitecc89d596597d7e450b69370233d6f23fa5728cf (patch)
tree4a45bd28895269309999ea98b29f0c87389e361c /screenshot.c
parente1654fa0171ea37be93e72ec7ef51d6b2543a6d7 (diff)
downloadopenttd-ecc89d596597d7e450b69370233d6f23fa5728cf.tar.xz
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
Simplification of the handling of the main_gui menus, Removal of repetitions and Hiding the internals of screenshots. Thanks to glx, Rubidium and Truelight for pointers
Diffstat (limited to 'screenshot.c')
-rw-r--r--screenshot.c45
1 files changed, 36 insertions, 9 deletions
diff --git a/screenshot.c b/screenshot.c
index 5cbe2012d..791957bc7 100644
--- a/screenshot.c
+++ b/screenshot.c
@@ -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 @@ void InitializeScreenshotFormats(void)
}
_cur_screenshot_format = j;
_num_screenshot_formats = lengthof(_screenshot_formats);
+ make_screenshot = SC_NONE;
}
const char *GetScreenshotFormatDesc(int i)
@@ -518,27 +520,52 @@ static char *MakeScreenshotName(const char *ext)
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;
+ }
+}
+