SUGGESTION: Game.SaveGameDirectory and/or ListBox.FillDirList with $SAVEGAMEDIR$

Started by monkey0506, Sun 30/12/2007 01:53:51

Previous topic - Next topic

monkey0506

We have the ability to redefine the save directory using Game.SetSaveGameDirectory, and for some functions (like File.Open if we need to use the save directory we can use the $SAVEGAMEDIR$ tag. However, not all functions make use of the $SAVEGAMEDIR$ tag, and there's no way for us to simply read it back.

If there were a Game.SaveGameDirectory property (read only of course; leaving the SetSaveGameDirectory function in place to reject invalid directories) then we could read the current save directory for functions that may need it.

Specifically I was working with ListBox.FillDirList when I realized that we can use fully qualified paths with this function such as "./dir/*.*" or even "D:/dir1/dir2/*.gif" but we simply cannot (unless we have explicitly set and stored elsewhere) know what the current save directory is set to.

Especially with the move toward keeping AGS files in the 'My Documents' folder to prevent Vista throwing a tantrum, I believe it important for us to be able to read back the fully-expanded current save directory; or at the very least, for ListBox.FillDirList to support the $SAVEGAMEDIR$ and $MYDOCS$ tags. That's not so much to ask, is it? :=

Rui 'Trovatore' Pires

You could set a string to be the same as the SaveGameDir, and use that string instead of a fullname path whenever trying to acess it, right? Or am I missing something?
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

monkey0506

Quote from: monkey_05_06 on Sun 30/12/2007 01:53:51(unless we have explicitly set and stored elsewhere)

That's what I meant here. Yes, I can keep track of it, but there are two important cases where this variable wouldn't/couldn't be updated properly: 1) the save directory changes elsewhere (in another script), 2) the 'My Documents' folder is used. Even if I keep track of what I have the save directory set to, I still wouldn't be able to use the My Documents folder in conjunction with ListBox.FillDirList.

Unless I can use environmental variables (get current Windows User)...but part of the benefit of the $MYDOCS$ tag was that it would default in other OSes. I could perhaps check if environmental variables work with ListBox.FillDirList and then if they do, I could check the OS and build the full path from there.... :o

The most direct route here seemed simply doing something such as:

Code: ags
lstList.FillDirList("%HOMEDRIVE%%HOMEPATH%\\MYDOCU~1\\SAVEDIR\\*.*");
// windows command prompt gave error here because %HOMEPATH% expands to a full directory with spaces in the name which it didn't like
// c:\> dir %HOMEDRIVE%%HOMEPATH%\MYDOCU~1\SAVEDIR\*.*


Although I couldn't seem to yield any results this way. I also tried:

Code: ags
lstList.FillDirList("\"%HOMEDRIVE%%HOMEPATH%\\MYDOCU~1\\SAVEDIR\\*.*\"");
// here windows command prompt yielded the expected results
// c:\> dir "%HOMEDRIVE%%HOMEPATH%\MYDOCU~1\SAVEDIR\*.*"


As well as substituting '/'s for '\\'s, but all to no avail. I couldn't find any results. So my conclusion is that FillDirList does not support environmental variables. Unless I've just done something entirely obtuse.

Actually I just found out about %USERPROFILE% (which is the same as %HOMEDRIVE%%HOMEPATH%) but still no luck getting it to work.

@Rui's post below:

#1 above meant that the save directory changed in another script (now slightly reworded). The code I'm working on is for a module, and #1 was referring to, say, another module modifying the save directory without providing some type of similar "this is what I have the save directory set to" variable globally accessible. ;)

Rui 'Trovatore' Pires

1) Ayuh, though you could set the string to whatever the new directory is, and all would be well.
2) Ah, I see.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Pumaman

ListBox.FillDirList supporting $SAVEGAMEDIR$ sounds like a reasonable request to me.

monkey0506

Thanks Chris! You're the greatest. AND back to work a day early!

SMF spam blocked by CleanTalk