From ed8482784e77c41bd20daec15033eb1adf835cf6 Mon Sep 17 00:00:00 2001 From: opa Date: Sat, 13 Jul 2024 23:45:03 +0900 Subject: [PATCH 1/2] Add %ROM_DIR%, %ES_CFG% tags --- README.md | 4 ++++ es-app/src/FileData.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 0f16f47a2..ba29b390a 100644 --- a/README.md +++ b/README.md @@ -272,6 +272,10 @@ 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. + +`%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. + See [SYSTEMS.md](SYSTEMS.md) for some live examples in EmulationStation. gamelist.xml diff --git a/es-app/src/FileData.cpp b/es-app/src/FileData.cpp index 1aa4f0f07..45de94bf8 100644 --- a/es-app/src/FileData.cpp +++ b/es-app/src/FileData.cpp @@ -291,10 +291,14 @@ void FileData::launchGame(Window* window) 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")); 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); Scripting::fireEvent("game-start", rom, basename, name); From 1f4f299689ff589b5dedb96bb91241c2929abdce Mon Sep 17 00:00:00 2001 From: opa Date: Tue, 20 Aug 2024 13:41:43 +0900 Subject: [PATCH 2/2] %CFG_DIR%, %INSTALL_DIR% --- README.md | 4 +++- es-app/src/FileData.cpp | 16 +++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ba29b390a..920e6e223 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/es-app/src/FileData.cpp b/es-app/src/FileData.cpp index 45de94bf8..86d68affd 100644 --- a/es-app/src/FileData.cpp +++ b/es-app/src/FileData.cpp @@ -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);