Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: SupSuper on Mon 26/03/2007 16:30:08

Title: Tweaking the built-in screenshot routine
Post by: SupSuper on Mon 26/03/2007 16:30:08
One thing that always bugged me about AGS was the built-in screenshot behavior was pretty plain, since it only takes one screenshot and that's that. Any further screenshots will overwrite the previous one.

So, for those game developers that want to let their users be screenshot-obsessed, here's some alternatives I came up with:

SaveDatedScreenShot()
This uses the current date/time for filename. A simple method to keep filenames unique.
Quote
function SaveDatedScreenShot()
{
   DateTime *dt = DateTime.Now;
   String filename = String.Format("%02d-%02d-%04d - %02d:%02d:%02d.bmp", dt.DayOfMonth, dt.Month, dt.Year, dt.Hour, dt.Minute, dt.Second);
   SaveScreenShot(filename);
}

SaveNumberedScreenShot()
Of course, if you have players that like to take lots of screenshots in a second, or just don't like the odd sorting from date-based names, you can also use this to have numbered screenshots. It's a bit more drawn out, but definitely no overwriting, and unlimited screenshots.
Quote
// Just a secondary function to check if a file exists, it's more organized than merging it with the primary one
function file_exists(String name)
{
   File *test = File.Open(name, eFileRead);
   if (test == null)
   {
      return false;
   }
   else
   {
      test.Close();
      return true;
   }
}

function SaveNumberedScreenShot()
{
   int i = 0;
   String filename = "screen0.bmp";
   // This loop detects the highest "unused" number, so players can delete and resort screenshots at will externally
   while (file_exists(filename))
   {
     i++;
     filename = String.Format("screen%d.bmp", i);
   }
   SaveScreenShot(filename);
}

I didn't feel this was worth a module, just a kind of "general tweaks" for anyone interested. Plus you can probably edit the functions a lot to make them more customizable or based on your personal preferences.
Title: Re: Tweaking the built-in screenshot routine
Post by: Akatosh on Mon 26/03/2007 16:44:51
This seems quite useful. Thank you!
Title: Re: Tweaking the built-in screenshot routine
Post by: Pumaman on Mon 26/03/2007 18:46:31
Quote from: SupSuper on Mon 26/03/2007 16:30:08
function SaveDatedScreenShot()
{
   DateTime *dt = DateTime.Now;
   String filename = String.Format("%02d/%02d/%04d - %02d:%02d:%02d.bmp", dt.DayOfMonth, dt.Month, dt.Year, dt.Hour, dt.Minute, dt.Second);
   SaveScreenShot(filename);
}

I'm surprised this works -- having a / in a filename will usually fail because it's seen as a directory separator. Therefore, to ensure compatibility it might be best to change the / to a -. Other than that, good work :)
Title: Re: Tweaking the built-in screenshot routine
Post by: SupSuper on Mon 26/03/2007 19:19:19
(Edit by strazer: NO NEED TO QUOTE THE WHOLE POST DIRECTLY ABOVE YOURS!)

Whoops you're right, fixed. Thanks :)