Problems with $SAVEGAMEDIR$ and screenshots

Started by Intangible, Thu 08/03/2012 13:45:18

Previous topic - Next topic

Intangible

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...

Khris

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

Calin Leafshade

A better way to do it is probably just to append the date and time instead of a number.

Intangible

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

Intangible

I'm forgetting about the actual solution... yes, using / instead of \ worked perfectly. And yes, it is a bit weird. :)

Thanks!

SMF spam blocked by CleanTalk