[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:
parent
a0f90f9877
commit
9ad2837a39
2
.gitignore
vendored
2
.gitignore
vendored
@ -28,6 +28,6 @@
|
||||
*bin/data
|
||||
*pack
|
||||
*core
|
||||
*screenshot.png
|
||||
screenshots/*.png
|
||||
*VERSION
|
||||
|
||||
|
2
screenshots/README
Normal file
2
screenshots/README
Normal file
@ -0,0 +1,2 @@
|
||||
I guess you can store some screenshots in here.
|
||||
|
30
src/player.c
30
src/player.c
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user