cfg files

Everything about development and the OpenMW source code.
Locked
User avatar
lgromanowski
Site Admin
Posts: 1193
Joined: 05 Aug 2011, 22:21
Location: Wroclaw, Poland
Contact:

cfg files

Post by lgromanowski » 13 Aug 2011, 21:24

Zini wrote: Over there at github Peppe and I had a discussion about the placement of cfg files. I think we should continue it here, because it also affects other parts of the project that are developed by other people.

The topic we were discussing is how to handle configuration for OpenMW when not installed.

I still think it would be best to have not installed OpenMW (used for development) and installed OpenMW (used for playing) not sharing any files/file locations. But this will make the whole situation a lot more complex. There is the launcher to consider and other files besides openmw.cfg.

So I am kinda agreen with Peppe's position now.

We have 3 locations for configuration files:

1. Global: This is system wide and affects all users.
2. Local: This is limited to one user. If the local file is missing or certain settings in the local file is missing, Global is used
3. Current (Directory): This is only used during development (when OpenMW is run without installing it). If this file is present, it will be used instead of Global.

I suggest, that by default we only place installation-specific settigns into Global (that would be data and resources for now).
Everything else (master, plugin and such) would go by default to local.

For OpenMW that means we can use Peppe's recent commit. But we must add a second openmw.cfg file, that is copied to the build directory (Current) and contains at least an adjusted resources path. Setting data to ./data might be a good idea too. The user, who is working with the uninstalled version of OpenMW can easily adjust these.

For the Launcher the situation is slightly more complicated. The first thing it needs to do it to pick up the location of the data directory. For this is must check Current first and if Current is not present, it should check Global (which might not be present either).
No matter what the result of this first step is, it needs to check Local afterwards and if it is there and has a data= entry, it must use this instead.
(if no data= entry is found at all, it probably should just quit with an error message).

For all other settings the launcher should use Local exclusively. Please note, that ogre.cfg needs to be written to the same directory where the Local openmw.cfg is located.
pvdk wrote: Ok, thanks for the heads up. No need for path.h then?
Oh and I would like to know where the files are put on Windows and Mac.
Zini wrote: No, you still need the path code (that we really should move into a component).
Peppe wrote: For windows I would assume the paths should be acquired using SHGetFolderPath/SHGetKnownFolderPath on FOLDERID_LocalAppData/FOLDERID_RoamingAppData (CSIDL_APPDATA) and FOLDERID_ProgramData (CSIDL_COMMON_APPDATA) and then applying some openmw directory on the end.

In other words the configuration would (commonly) be somewhere under
C:\Documents and Settings\All Users\Application Data
C:\Documents and Settings\<user>\Application Data
or something similar (seems they renamed the paths a bit with vista)
pvdk wrote: No need for MFC code when we use Qt.
Something like:

Code: Select all

#ifdef Q_WS_WIN
QString appDir = QDir::homePath() + "/Application Data/openmw";
#elif defined(Q_WS_X11)
QString appDir = QDir::homePath() + "/.config/openmw/";
#endif 
Will do the job.
I have no idea however how this translates to different versions of Windows and what is considered our Global and our Local directory. Maybe we could read it from the registry?
Also, where does Mac store its config files?

Edit: Found a regkey in the same QtCentre topic I found the above code in. It's "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Explorer\Shell Folders" and here's a page with the different values it holds: Shell Folders

Which value should I use?
Greendogo wrote: Edited out naivety :D
pvdk wrote:
Greendogo wrote:This may sound a little naive, but concerning installing OpenMW...
Yeah I agree. What I'd like to know (as a programmer :) ) how do we know if OpenMW is installed or not. I would suggest this load order:

1. Current directory
2. User directory
3. Global directory
Peppe wrote:
pvdk wrote:
Greendogo wrote:This may sound a little naive, but concerning installing OpenMW...
Yeah I agree. What I'd like to know (as a programmer :) ) how do we know if OpenMW is installed or not.
I don't see how it matters.
pvdk wrote:I would suggest this load order:
  1. Current directory
  2. User directory
  3. Global directory

Sounds like a strange order to me.

The way I see it load order should be
  1. Global or local configuration
  2. User configuration
Or I could consider
  1. Global configuration
  2. Local configuration
  3. User configuration
Configuration read later override previously read configuration (on a per value basis).
Any changes should be written to user configuration, we are not likely to have access to write to anything else.

The reason to always read the user configuration last is that it should be able to override all. I as a user would not appreciate if the settings I have chosen are ignored.
pvdk wrote: I guess it matters because you propose a difference between installed OpenMW and not-installed OpenMW which the launcher needs to know in order to retrieve the correct config file.

What exactly you mean with User/Local because now I'm confused :?

This is what I thought we were talking about&#058;
Global location = /etc/xdg/ or system equivalent
User location = /home/username/.config or system equivalent
Local location = current working directory
Peppe wrote:
pvdk wrote:I guess it matters because you propose a difference between installed OpenMW and not-installed OpenMW which the launcher needs to know in order to retrieve the correct config file.
No? The proposal is about accepting a 3rd configuration file location and which priority these three files should have.
Then whether it is 'installed' or not only affects the likelihood of which files exists, but does not guarantee anything.
pvdk wrote:What exactly you mean with User/Local because now I'm confused :?

This is what I thought we were talking about:
Global location = /etc/xdg/ or system equivalent
User location = /home/username/.config or system equivalent
Local location = current working directory
Something like that yes.
pvdk wrote: Ok, that clears things up a bit.

I still go for my proposed load order of pwd, home, global. People who need the development config file in place usually know what they do so it should have priority over the other files IMHO.
About the home then global order: That's the way Qt handles settings locations and it sounds reasonable to me.
Zini wrote: I did a bit more work on peppe's config branch. A local openmw.cfg file is now created with reasonable defaults.

I am not really sure, if it will work on OS X though. The related cmake script part looks a bit cryptic to a non-OS X user. Could someone test please?

(btw. we are currently going for Peppe's original proposal regarding cfg priorities/order)
pvdk wrote: Nice. Looking at the commits it seems that:
OpenMW checks if there's a config file in the current working directory, if it's not there it checks the global directory. Is that correct?
(Because that is almost the load order I proposed)
Zini wrote: Correct.
best regards,
Lukasz

Locked