[Fix] Screenshots will allow up to 128 shots now without overwriting. These will go to a nice screenshots directory for you.

This commit is contained in:
Allanis 2013-02-20 21:37:02 +00:00
parent a0f90f9877
commit 9ad2837a39
3 changed files with 30 additions and 6 deletions

2
.gitignore vendored
View File

@ -28,6 +28,6 @@
*bin/data
*pack
*core
*screenshot.png
screenshots/*.png
*VERSION

2
screenshots/README Normal file
View File

@ -0,0 +1,2 @@
I guess you can store some screenshots in here.

View File

@ -964,11 +964,33 @@ void player_brokeHyperspace(void) {
}
// Take a screenshot.
static int screenshot_cur = 0;
void player_screenshot(void) {
char filename[20];
// TODO not overwirte old screenshots.
strncpy(filename, "screenshot.png", 20);
DEBUG("SCREENSHOT!");
FILE* fp;
int done;
char filename[PATH_MAX];
done = 0;
do {
if(screenshot_cur >= 128) {
// Just incase I fucked up. :)
WARN("You have reached the maximum amount of screenshots [128]");
return;
}
snprintf(filename, PATH_MAX, "../screenshots/screenshot%03d.png", screenshot_cur);
fp = fopen(filename, "r"); // Myeah, I know it's a horrible way to check.
if(fp == NULL) done = 1;
else {
// Next.
screenshot_cur++;
fclose(fp);
}
fp = NULL;
} while(!done);
// Now gief me that screenshot.
DEBUG("Taking screenshot [%03d]..", screenshot_cur);
gl_screenshot(filename);
}