Skip to content

Commit

Permalink
Allow multiple screenshots and videos to be saved
Browse files Browse the repository at this point in the history
  • Loading branch information
RobLoach committed Dec 19, 2020
1 parent a24bd33 commit 388e1a8
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/studio/studio.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
#define MD5_HASHSIZE 16
#define BG_ANIMATION_COLOR tic_color_dark_grey

static const char VideoGif[] = "video.gif";
static const char ScreenGif[] = "screen.gif";
static const char VideoGif[] = "video%i.gif";
static const char ScreenGif[] = "screen%i.gif";

typedef struct
{
Expand Down Expand Up @@ -1454,16 +1454,26 @@ static void stopVideoRecord(const char* name)
{
s32 size = 0;
u8* data = malloc(FRAME_SIZE * impl.video.frame);
int i = 0;
char filename[TICNAME_MAX];

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

if(fsSaveFile(impl.fs, name, data, size, true))
// Find an available filename to save.
do
{
snprintf(filename, sizeof filename, name, ++i);
}
while(fsExistsFile(impl.fs, filename));

// Now that it has found an available filename, save it.
if(fsSaveFile(impl.fs, filename, data, size, true))
{
char msg[TICNAME_MAX];
sprintf(msg, "%s saved :)", name);
sprintf(msg, "%s saved :)", filename);
showPopupMessage(msg);

getSystem()->openSystemPath(fsGetFilePath(impl.fs, name));
getSystem()->openSystemPath(fsGetFilePath(impl.fs, filename));
}
else showPopupMessage("error: file not saved :(");
}
Expand Down

0 comments on commit 388e1a8

Please sign in to comment.