radiant: introduce transformpath lib and make use of it to transform engine path
The idea is to allow environment-specific paths in netradiant game packs.
The transformpath
library add support for some keywords, keywords may be named like environment variables but this is not an environment variable parser.
For example the WarFork gamepack already has an engine path making use of ~
, which is not resolved prior to this change.
The current implementation only transform engine path, at some point we may also support home path transformation (it would require to update the gamepack specification).
This is not an environment variable parser, this only supports
a set of keywords using common environment name syntax when it
exists to make the strings easier to read.
Supported substitution keywords,
Windows:
- %HOMEPATH%
- %USERPROFILE%
- %ProgramFiles%
- %ProgramFiles(x86)%
- %ProgramW6432%
- %APPDATA%
- [CSIDL_MYDOCUMENTS]
Supported substitution keywords,
Linux, FreeBSD, macOS:
- ~
- ${HOME}
Supported substitution keywords,
Linux, FreeBSD, other XDG systems:
- ${XDG_CONFIG_HOME}
- ${XDG_DATA_HOME}
Examples,
game engine directories:
- Windows: %ProgramFiles%\Unvanquished
- Linux: ${XDG_DATA_HOME}/unvanquished/base
- macOS: ${HOME}/Games/Unvanquished
Examples,
game home directories:
- Windows: [CSIDL_MYDOCUMENTS]\My Games\Unvanquished
- Linux: ${XDG_DATA_HOME}/unvanquished
- macOS: ${HOME}/Application Support/Unvanquished
Edited by Thomas Debesse