Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add %ROM_DIR%, %CFG_DIR%, %INSTALL_DIR% tags #881

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,12 @@ The following "tags" are replaced by ES in launch commands:

`%ROM_RAW%` - Replaced with the unescaped, absolute path to the selected ROM. If your emulator is picky about paths, you might want to use this instead of %ROM%, but enclosed in quotes.

`%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.

`%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.

gamelist.xml
Expand Down
14 changes: 10 additions & 4 deletions es-app/src/FileData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +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 = 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, "%CFG_DIR%", cfg_dir);
command = Utils::String::replace(command, "%INSTALL_DIR%", install_dir);

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

Expand Down