BASE: Add default extrapath and themepahth when running in tree

This means building and running scummvm in tree now works out of the box.

Unfortnatelly registering them as defaults would not work as
ConfMan::hasKey() returns false when only defined as a default, and
in most places this is checked before using those paths. So if we
wanted to use defaults we would need to replace all those checks with
a check that the path is not empty.

There is a drawback to using the session domain though: it takes
priority over all other domains. So a custom extrapath defined for
a game will be ignored. We try to mitigate the issue by only adding
those path if they exist(so that it does not break shadow builds for
example).

Also the change is excluded on Windows as it is not needed there
since the themes and engine data files are embedded in the executable.
This commit is contained in:
Thierry Crozat
2023-03-23 19:41:20 +00:00
committed by Eugene Sandulenko
parent 4f2cfc4af5
commit be98f2a812
+14
View File
@@ -1991,6 +1991,20 @@ bool processSettings(Common::String &command, Common::StringMap &settings, Commo
ConfMan.set(key, value, useSessionDomain ? Common::ConfigManager::kSessionDomain : Common::ConfigManager::kTransientDomain);
}
// In non-release builds, if themepath and extrapath are not defined yet, add them to the session path so that it works out
// of the box when building and running in tree.
#if !defined(RELEASE_BUILD) && !defined(WIN32)
#define ADD_DEFAULT_PATH(key, path) \
if (!ConfMan.hasKey(key)) { \
Common::FSNode node(path); \
if (node.exists() && node.isDirectory() && node.isReadable()) \
ConfMan.set(key, path, Common::ConfigManager::kSessionDomain); \
}
ADD_DEFAULT_PATH("themepath", "gui/themes/")
ADD_DEFAULT_PATH("extrapath", "dists/engine-data/")
#endif
return false;
}