Skip to content

Commit

Permalink
%CFG_DIR%, %INSTALL_DIR%
Browse files Browse the repository at this point in the history
  • Loading branch information
o-p-a committed Aug 20, 2024
1 parent ed84827 commit 1f4f299
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,9 @@ The following "tags" are replaced by ES in launch commands:

`%ROM_DIR%` - Replaced with the dirname (except "/base.ext") of the selected ROM. Use this when you need to chdir to the directory where the ROM.

`%ES_CFG%` - Replaced with the directory path of the EmulationStation configuration file contains (i.e. your .emulationstation directory). If .emulationstation is symlink, the link will resolved.
`%CFG_DIR%` - Replaced with the directory path of the EmulationStation configuration file contains (i.e. your .emulationstation directory).

`%INSTALL_DIR%` - Replaced with the directory path of the EmulationStation executable file contains.

See [SYSTEMS.md](SYSTEMS.md) for some live examples in EmulationStation.

Expand Down
16 changes: 9 additions & 7 deletions es-app/src/FileData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,18 +287,20 @@ void FileData::launchGame(Window* window)

std::string command = mEnvData->mLaunchCommand;

const std::string rom = Utils::FileSystem::getEscapedPath(getPath());
const std::string basename = Utils::FileSystem::getStem(getPath());
const std::string rom_raw = Utils::FileSystem::getPreferredPath(getPath());
const std::string name = getName();
const std::string rom_dir = Utils::FileSystem::getPreferredPath(Utils::FileSystem::getParent(getPath()));
const std::string es_cfg = Utils::FileSystem::getPreferredPath(Utils::FileSystem::getCanonicalPath(Utils::FileSystem::getHomePath() + "/.emulationstation"));
const std::string rom = Utils::FileSystem::getEscapedPath(getPath());
const std::string basename = Utils::FileSystem::getStem(getPath());
const std::string rom_raw = Utils::FileSystem::getPreferredPath(getPath());
const std::string name = getName();
const std::string rom_dir = Utils::FileSystem::getPreferredPath(Utils::FileSystem::getParent(getPath()));
const std::string cfg_dir = Utils::FileSystem::getPreferredPath(Utils::FileSystem::getCanonicalPath(Utils::FileSystem::getHomePath() + "/.emulationstation"));
const std::string install_dir = Utils::FileSystem::getPreferredPath(Utils::FileSystem::getCanonicalPath(Utils::FileSystem::getExePath()));

command = Utils::String::replace(command, "%ROM%", rom);
command = Utils::String::replace(command, "%BASENAME%", basename);
command = Utils::String::replace(command, "%ROM_RAW%", rom_raw);
command = Utils::String::replace(command, "%ROM_DIR%", rom_dir);
command = Utils::String::replace(command, "%ES_CFG%", es_cfg);
command = Utils::String::replace(command, "%CFG_DIR%", cfg_dir);
command = Utils::String::replace(command, "%INSTALL_DIR%", install_dir);

Scripting::fireEvent("game-start", rom, basename, name);

Expand Down

0 comments on commit 1f4f299

Please sign in to comment.