diff --git a/README_DEV.md b/README_DEV.md index affafae..14dc63f 100644 --- a/README_DEV.md +++ b/README_DEV.md @@ -14,4 +14,4 @@ to access some (rather crude) debugging and development stuff, activated by pres * [6] - Immediately complete the current mission * [9] - Show the current frames per second -* [0] - Take a screenshot once per second. Assumes the existance of dev/screenshots/tmp relative to the game's binary +* [0] - Take a screenshot once per second, saving to /tmp/tbftss on Linux. diff --git a/src/draw/draw.c b/src/draw/draw.c index 57248f2..73f42d2 100644 --- a/src/draw/draw.c +++ b/src/draw/draw.c @@ -189,7 +189,7 @@ void saveScreenshot(void) char filename[MAX_NAME_LENGTH]; SDL_Surface *sshot; - sprintf(filename, "dev/screenshots/tmp/%d.bmp", ++i); + sprintf(filename, "/tmp/tbftss/%d.bmp", ++i); sshot = SDL_CreateRGBSurface(0, SCREEN_WIDTH, SCREEN_HEIGHT, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); SDL_RenderReadPixels(app.renderer, NULL, SDL_PIXELFORMAT_ARGB8888, sshot->pixels, sshot->pitch); diff --git a/src/main.c b/src/main.c index a0502a5..c1d08d7 100644 --- a/src/main.c +++ b/src/main.c @@ -167,6 +167,8 @@ static void handleArguments(int argc, char *argv[]) if (strcmp(argv[i], "-debug") == 0) { dev.debug = 1; + + createScreenshotFolder(); } } } diff --git a/src/main.h b/src/main.h index 5a0b35f..d005cc7 100644 --- a/src/main.h +++ b/src/main.h @@ -48,6 +48,7 @@ extern void initLookups(void); extern void initGame(void); extern void doKeyDown(SDL_KeyboardEvent *event); extern void doKeyUp(SDL_KeyboardEvent *event); +extern void createScreenshotFolder(void); App app; Colors colors; diff --git a/src/plat/unix/unixInit.c b/src/plat/unix/unixInit.c index f4307fb..aa09b9a 100644 --- a/src/plat/unix/unixInit.c +++ b/src/plat/unix/unixInit.c @@ -44,3 +44,10 @@ void createSaveFolder(void) STRNCPY(app.saveDir, dir, MAX_FILENAME_LENGTH); } + +void createScreenshotFolder(void) +{ + mkdir("/tmp/tbftss", S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH); + + dev.screenshotFolder = "/tmp/tbftss"; +} diff --git a/src/plat/unix/unixInit.h b/src/plat/unix/unixInit.h index 7088e14..a74f64d 100644 --- a/src/plat/unix/unixInit.h +++ b/src/plat/unix/unixInit.h @@ -26,3 +26,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "../../common.h" extern App app; +extern Dev dev; diff --git a/src/plat/win32/win32Init.c b/src/plat/win32/win32Init.c index e3b8975..6e08fc8 100644 --- a/src/plat/win32/win32Init.c +++ b/src/plat/win32/win32Init.c @@ -44,3 +44,8 @@ void createSaveFolder(void) STRNCPY(app.saveDir, dir, MAX_FILENAME_LENGTH); } + +void createScreenshotFolder(void) +{ + dev.screenshotFolder = "./"; +}