Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Intangible on Thu 08/03/2012 13:45:18

Title: Problems with $SAVEGAMEDIR$ and screenshots
Post by: Intangible on Thu 08/03/2012 13:45:18
I'm trying to improve the default screenshot handling so that the game doesn't just keep overwriting the same screenshot (someone already took a shot at this here... http://www.adventuregamestudio.co.uk/yabb/index.php?topic=30666.0 ...but their numbered screenshot implementation didn't work for me). This is what I have so far:

function TakeScreenshot()
{
  int picNumber = 0;
  String fileName = String.Format("screenshot%d.bmp", picNumber);
 
  while (File.Exists(String.Format("$SAVEGAMEDIR$\%s", fileName)))
  {
    picNumber++;
    fileName = String.Format("screenshot%d.bmp", picNumber);
  }
 
  SaveScreenShot(fileName);
}

I'm trying to use the $SAVEGAMEDIR$ tag like the help file said, so that it knows to look in the save game directory, but the File.Exists call always seems to be returning true and the same screenshot is overwritten again and again. Any suggestions? The screenshots are appearing in C:UsersMyUserNameSaved GamesMyGameName. I'm assuming that it would be horribly foolish to hardcode that path, which is why I was really hoping the tag would work...
Title: Re: Problems with $SAVEGAMEDIR$ and screenshots
Post by: Khris on Thu 08/03/2012 15:07:20
It's a bit weird but it looks like you're supposed to use a / in paths.
Replacing the \ with a / in your function made it work for me.

(btw, File.Exists did return false every time, not true.)
Title: Re: Problems with $SAVEGAMEDIR$ and screenshots
Post by: Calin Leafshade on Thu 08/03/2012 15:19:50
A better way to do it is probably just to append the date and time instead of a number.
Title: Re: Problems with $SAVEGAMEDIR$ and screenshots
Post by: Intangible on Fri 09/03/2012 00:47:10
Quote from: Calin Leafshade on Thu 08/03/2012 15:19:50
A better way to do it is probably just to append the date and time instead of a number.

I don't know... I kind of like the abitrary, incremental numbering, because it's certain to produce a unique file name everytime. If I want to know the screenshot's date/time, I can always check the "DateModified" file attribute in Windows Explorer. But to each his own. :)
Title: Re: Problems with $SAVEGAMEDIR$ and screenshots
Post by: Intangible on Fri 09/03/2012 00:48:38
I'm forgetting about the actual solution... yes, using / instead of \ worked perfectly. And yes, it is a bit weird. :)

Thanks!