Tweaking the built-in screenshot routine

Started by SupSuper, Mon 26/03/2007 16:30:08

Previous topic - Next topic

SupSuper

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.
Programmer looking for work

Akatosh


Pumaman

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 :)

SupSuper

#3
(Edit by strazer: NO NEED TO QUOTE THE WHOLE POST DIRECTLY ABOVE YOURS!)

Whoops you're right, fixed. Thanks :)
Programmer looking for work

SMF spam blocked by CleanTalk