Skip to content

radiant: introduce transformpath lib and make use of it to transform engine path

Thomas Debesse requested to merge illwieckz/transformpath into master

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.

https://gitlab.com/netradiant/gamepacks/warfork-mapeditor-support/-/blob/bdee1d8abc0fc1bb988756dfa3db64779f78c1d0/games/warfork.game#L6

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

Merge request reports