• entries
    500
  • comments
    1888
  • views
    333504

User Settings

Sign in to follow this  
EDI

91 views

Whew, last night saw a big revision to the engine, but it is one that adds just that extra bit more of refinement.

In the begining:

Game developers would install to the C: drive, and store their save game files, preferences and lord knows what else in C:\MyGame

Times have changed however, and I'm happy to say that I've changed with them, even if it has been late in coming =)

The new world:

For those of you that don't know I'm talking about storing settings and files in a windows friendly way. Most of us know that we install to C:\Program Files
but most of us also store save-games, and settings in there too, while this is convienent it's not the 'best' method.

Optimaly your game should be windows-user-aware. This means that is is fine to have read-only settings queried from Program Files, but everything you store (Screen Format, mouse speed, UI positions, save games, text speed, etc.) should be saved user-local.

That is:

C:\Documents and Settings\username\Application Data\my company name\my product name

this path can be aquired via the Shell API functions such as SHGetFolderPath

by storing your default settings in program files, and storing/reading your user settings from there, your game now has custom settings for each user.

Save Games

In the case of save-games, there a times where you want to keep your save game private, or availible to everyone, this can be achived by asking the user which they would like before they save.

If they choose 'save for everyone'

you save to:
C:\Documents and Settings\all users\Application Data\my company name\my product name

again this directory can be aquired via the shell functions

If they choose 'save for only me'

you save to:
C:\Documents and Settings\username\Application Data\my company name\my product name

An alternative approach is somtimes games will save to:

C:\Documents and Settings\username\My Documents\My Games\my product

this is a valid approach, but only really useful if there is a reason to allow normal and frequent moving of game files.

Conclusion:

Making your game aware of the current user and storing settings relative to them gives your game more robust operation. While it means little for single user machines, machines with multiple users will appreciate these added features.
Sign in to follow this  


5 Comments


Recommended Comments

My latest game has been doing this for weeks, on OS X and Windows. I believe John Hattan is also now using my code for it.

Share this comment


Link to comment
EDIT: God, how did I miss that you SAY you're using SHGetFolderPath in your text? Sorry about that. I'll leave this post anyway, in case people want to see the parameters for it or something. Whoops!

You're probably already doing it this way, but for the help of anyone else who is reading this:

Instead of hardcoding the directory as C:\Documents And Settings\...\Application Data, you should use the following function to get the path to the application data directory:


TCHAR appDataString[MAX_PATH+1];
SHGetFolderPath(0,CSIDL_LOCAL_APPDATA,0,SHGFP_TYPE_CURRENT, appDataString);


That way, if the user has changed where the application data directory is, or if it's installed on a drive that's not C:, or anything else, it'll still go to the correct place.

Share this comment


Link to comment
Quote:
Original post by Drilian

TCHAR appDataString[MAX_PATH+1];
SHGetFolderPath(0,CSIDL_LOCAL_APPDATA,0,SHGFP_TYPE_CURRENT, appDataString);



Sweet :)

Share this comment


Link to comment
awesome! a really nice feature!

I personally hate those that save to My Documents. I hate all programs that add folders there, it just clutters up... (My Recieved Files and My Recieved Skype Files anyone?...). So saving to the users app folder ftw!

I'm someone that likes to save his saves, like store them in a .zip file if I ever install the game again. This can be a bit tricky now since most users won't know where to find them. I don't think many people do this to warant it as a in-game/engine feature, but you could just put a saves_readme.txt or a saves/readme.txt that tells people where they can find their savefiles? :)

keep up the great work EDI!

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now