Hey guys, what have you found to be the best approach to user settings. We are starting to get to a point where we have more tools that require user specific options. My current system is to store things in a JSON file. so far so good, the overhead for the read/write is pretty minimal so I dont see that impacting the user at all.
Do you guys use a different approach?
How do you display the settings to the user? Single UI?
What other approaches should be considered?
I would use maya’s optionVar, but these settings may be used by other tools so I don’t want to keep two separate settings files/systems going.
Thanks
We have an application launcher that our entire team uses to launch various tools and other executables. This tool sets environment variables for parameters that are shared across different tools and verifies that the environment is set up correctly. We use optionVars for anything Maya specific.
How do present the ui to change options? Do you manually add new ui widgets or is it somehow automated?
I’ve been writing a user settings system recently which sounds similar to your current approach TheMaxx. The settings are grouped into categories (generally one category per tool) which are displayed as pages in a shared settings dialogue. I also store a GUI expose type along with each setting which defines how (and if) it will be displayed in the UI (e.g. whether a string should be treated as a path or not). The data is all stored as nested dictionaries with a single class instance as the interface which all the tools use for read/writing. The settings dictionary is then dumped to disk via cjson. By default I also tend to defer the write to limit disk access and serialisation time.
I was wondering about the UI defs and whether or not to keep them with the settings or in some other file/structure. I’ll try it as you are and see how she goes. I haven’t been keeping a module global around so the file was being read on each variable read. It’s a little lazy, but you always have correct data and the overhead never seemed to be an issue.
I was also tinkering with the idea of a cloud based system and possibly have some local file for a fallback, but that’s probably overkill
Yea using a cache is obviously just an optimisation which probably isn’t really necessary especially if there isn’t much data. I mainly did it because it was simple to implement and for the sake of future proofing as more settings are added over time.
Also, if you read and write to the cache then your data is always correct even if it hasn’t been saved to disk yet. Within Maya I defer my settings to save on Idle which effectively means the only time your disk version is out of sync with the in memory cache is while a script is running. It also means that writing to disk is always skipped if you’re running in batch mode which can be useful :). If you wanted to be super optimised then you could probably even defer saving until Maya closes or if the user saves them explicitly (similar to how Maya handles its own settings). I don’t trust it enough not to crash to do that though :P.