Jump to content

Ultra Software Company Blog

  • entries
    188
  • comments
    1,259
  • views
    686,125

Contributors to this blog

Saving In-Game Settings


Josh

4,355 views

 Share

An update is up which saves all menu settings into your game's config file.  When your program calls System:SetProperty() the inputted key-value pair is saved in a list of settings.  Your game automatically saves these settings to a file when it closes, located in C:\Users\<USERNAME>\AppData\local\<GAMENAME>\<GAMENAME>.cfg.

The contents of the config file will look something like this:

anisotropicfilter=8
antialias=1
lightquality=1
screenheight=720
screenwidth=1280
session_number=2
terrainquality=1
texturedetail=0
trilinearfilter=1
verticalsync=1
waterquality=1

When your game runs again, these settings will be automatically loaded and applied.  You can override config settings with a command line argument.  However, command lines arguments will not be saved in the config file.

This has been my plan for a long time, and is the reason why your game is not set to use the editor settings.  Setting for running your game in real-time should be separate from editor settings.

  • Like 1
  • Upvote 4
 Share

9 Comments


Recommended Comments

45 minutes ago, Genebris said:

Is it possible to change location of config file?

You can make your own file, but this location is recommended.

The config file also works with sandboxing enabled.

Link to comment
1 hour ago, Genebris said:

But System:SetProperty works only with standard path?

Why would you need to save a config file in another location?  This is the correct path you are supposed to use, and it will always have red/write priveleges.

Link to comment

As a player, I hate to search for config and save files somewhere on C drive, I like when they are inside game folder. I think I'll write to file myself then.

Link to comment
11 minutes ago, Genebris said:

As a player, I hate to search for config and save files somewhere on C drive, I like when they are inside game folder. I think I'll write to file myself then.

You're going to have problems with Windows blocking write access to that folder.

Link to comment

Yeah windows hates when things write outside the users folder. You will have better luck putting the game saves in the documents folder like other games.

Link to comment

My menu already had this functionality, but I'll take a look to see how you've done it. I was a bit worried about the default settings since they vary based on user's hardware.

34 minutes ago, Einlander said:

Yeah windows hates when things write outside the users folder. You will have better luck putting the game saves in the documents folder like other games.

As for the cfg/log files,If you have the Pro edition, it's possible to do this on your own but I recommend it's the new default with 4.x or LE5. 

AppData is always on the C Drive (Or where the OS is installed), while Documents is a user's library that can have any location set by user. Many other games do this, and I wonder how Source gets away with writing to the game folder. (I never had issues saving files to the game dir, but Windows prob sees it as "my app" and allows it...)

Link to comment
2 minutes ago, reepblue said:

AppData is always on the C Drive (Or where the OS is installed), while Documents is a user's library that can have any location set by user. Many other games do this, and I wonder how Source gets away with writing to the game folder. (I never had issues saving files to the game dir, but Windows prob sees it as "my app" and allows it...)

Steam always runs in admin mode, and all Steam games receive those privileges.

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...