Skip to content

Commit 61b6515

Browse files
authored
Merge pull request #1278 from RobLoach/multiplescreens
Allow multiple screenshots and videos to be saved
2 parents a24bd33 + 388e1a8 commit 61b6515

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/studio/studio.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@
6363
#define MD5_HASHSIZE 16
6464
#define BG_ANIMATION_COLOR tic_color_dark_grey
6565

66-
static const char VideoGif[] = "video.gif";
67-
static const char ScreenGif[] = "screen.gif";
66+
static const char VideoGif[] = "video%i.gif";
67+
static const char ScreenGif[] = "screen%i.gif";
6868

6969
typedef struct
7070
{
@@ -1454,16 +1454,26 @@ static void stopVideoRecord(const char* name)
14541454
{
14551455
s32 size = 0;
14561456
u8* data = malloc(FRAME_SIZE * impl.video.frame);
1457+
int i = 0;
1458+
char filename[TICNAME_MAX];
14571459

14581460
gif_write_animation(data, &size, TIC80_FULLWIDTH, TIC80_FULLHEIGHT, (const u8*)impl.video.buffer, impl.video.frame, TIC80_FRAMERATE, getConfig()->gifScale);
14591461

1460-
if(fsSaveFile(impl.fs, name, data, size, true))
1462+
// Find an available filename to save.
1463+
do
1464+
{
1465+
snprintf(filename, sizeof filename, name, ++i);
1466+
}
1467+
while(fsExistsFile(impl.fs, filename));
1468+
1469+
// Now that it has found an available filename, save it.
1470+
if(fsSaveFile(impl.fs, filename, data, size, true))
14611471
{
14621472
char msg[TICNAME_MAX];
1463-
sprintf(msg, "%s saved :)", name);
1473+
sprintf(msg, "%s saved :)", filename);
14641474
showPopupMessage(msg);
14651475

1466-
getSystem()->openSystemPath(fsGetFilePath(impl.fs, name));
1476+
getSystem()->openSystemPath(fsGetFilePath(impl.fs, filename));
14671477
}
14681478
else showPopupMessage("error: file not saved :(");
14691479
}

0 commit comments

Comments
 (0)